Unlike your typical computer where you usually shutdown properly, I cannot rely on this during the use of my Raspberry Pi. If the Raspberry Pi is improperly shutdown too many times, data corruption in the file system leading to unbootable SD card may result. So we should use a read-only file system.
Full instructions and explanations are obtained from this link but you can run these commands directly. I modified some of the instructions for personal convenience.
Login with default username: alarm, password: alarm
#Optionally enable root over SSH. The rest of these instructions assume u are in root.
su
nano /etc/ssh/sshd_config
#Add "PermitRootLogin yes" to the Authentication section after "#PermitRootLogin prohibit-password" then save
reboot
#Login as root
#Update everything first, remove cache then reboot to detect problems
pacman -Syu
# Delete certs if you see a message like "/etc/ssl/certs/ca-certificates.crt exists in filesystem" then rerun pacman -Syu
rm /etc/ssl/certs/ca-certificates.crt
#May be needed if the pacman version has changed during the update
pacman-db-upgrade
#Optional if you want to clear the cache
pacman -Sc
reboot
#Change timezone (optional)
rm /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Singapore /etc/localtime
#Relocate DNS cache (This step causes DNS problems on the latest Arch Linux ARM kernels so skip this)
#rm /etc/resolv.conf
#ln -s /tmp/resolv.conf /etc/resolv.conf
#Adjust /etc/fstab, add/modify to the following hashed lines. Mount certain directories to RAM disk.
nano /etc/fstab
#Add the following lines up to the #end. Include the first commented line in case you have to set to write enabled next time.
#/dev/mmcblk0p1 /boot vfat defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults,ro,errors=remount-ro 0 0
tmpfs /var/log tmpfs nodev,nosuid 0 0
tmpfs /var/tmp tmpfs nodev,nosuid 0 0
#end
#Adjust journald service to not log the system log to prevent flooding of the /var/log folder
nano /etc/systemd/journald.conf
#Uncomment and set "Storage=none"
#To mount / partition as read-only
nano /boot/cmdline.txt
#Replace the "rw" flag with the "ro" flag right after the root= parameter.
#Disable systemd services
#systemctl disable systemd-readahead-collect #Not working now
systemctl disable systemd-random-seed
#systemctl disable ntpd #Not working now
#Put shortcut shell scripts to re-enable read-write temporarily if needed
printf "mount -o remount,rw /\nmount -o remount,rw /boot" > writeenable.sh
printf "mount -o remount,ro /\nmount -o remount,ro /boot" > readonly.sh
chmod 500 writeenable.sh
chmod 500 readonly.sh
#Change your password if needed (Optional)
"passwd root" or "passwd alarm"
#Remove history
history -c -w
reboot
To enable read-write temporarily to do say an update, just run ./writeenable.sh
.
@yeokm1, I have the same issue as tyriis. Im continuously pinging the pi from my pc and after a certain time(usually >4 hrs) the pi becomes unreachable. At this time my screen also blanks out. There are several posts about lightdm not being able to run on a read only file system. I believe the display blanking out could be related to that but what stumps me is that this issue always happens after at least 4 hrs of up time.
Here is my setup(borrowed mostly from https://narcisocerezo.wordpress.com/2014/06/25/create-a-robust-raspberry-pi-setup-for-24x7-operation/)
proc /proc proc defaults 0 0
/dev/mmcblk06 /boot vfat defaults,ro 0 2
/dev/mmcblk07 / ext4 defaults,noatime,ro 0 1
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0
tmpfs /var/lib/systemd tmpfs defaults,noatime,mode=0755 0 0
tmpfs /run tmpfs defaults,noatime,mode=0755 0 0
tmpfs /var/lib/lightdm tmpfs defaults,noatime,nosuid,size=30m 0 0
$ sudo update-rc.d -f dphys-swapfile remove
$ sudo swapoff /var/swap
$ sudo rm /var/swap
The following settings may not be relevant to the issues but im posting them anyway for the sake of completeness.
#!/bin/sh
test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate --state /var/log/logrotate.state /etc/logrotate.conf
3. Disable man-db indexing and fake-hw clock.
So far i have been unable to look at the logs to see what is causing the error because i mounted /var/log on tmpfs. I have since redirected the logs to a usb drive. I am now waiting for the failure to occur. I will post the logs as soon as i have them.
If you have seen this issue before, please point me in the right direction.
Anvesh