Rpi/File System Corruption Prevention
How to mark the / and /boot partitions read-only
See: http://geraldnaveen.blogspot.com/2013/11/fixing-raspberry-pi-filesystem.html
You could do this from Pi itself, or on a different machine. Just edit /etc/fstab and add 'ro' in the flags as shown below:
/dev/mmcblk0p1 /boot vfat defaults,ro 0 2 /dev/mmcblk0p2 / ext4 defaults,ro,noatime 0 1
Now reboot the Pi and it should boot with both these mount points in read-only mode. You could do a mount to verify, it should look something similar to this:
/dev/root on / type ext4 (ro,noatime,data=ordered) devtmpfs on /dev type devtmpfs (rw,relatime,size=216108k,nr_inodes=54027,mode=755) tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=44876k,mode=755) tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=89740k) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620) /dev/mmcblk0p1 on /boot type vfat (ro,relatime,fmask=0022, dmask=0022, codepage=cp437, iocharset=ascii,shortname=mixed, errors=remount-ro) tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,size=89740k)
Note: Some services (like apache2) might fail to start, because they can't write to disk. You might have to check individual services to figure out what they are trying to write and resolve it appropriately. For eg., apache2 writes log files /var/log/apache2. It is best to disable logging. If there is not too much logging, you could map the log folder to /tmp (tmpfs -- as shown in mount).