Sometimes you want to make sure that any file operations OS does don’t corrupt your file system because of a sudden shutdown. The most common culprit is usually the /tmp folder. Adding the following lines of code to your fstab will make the OS write any temporary files to RAM. This not only saves your SD card from multiple writes, but makes sure that, given no other file system activity, you can just unplug your Pi without consequences:
sudo nano /etc/fstab tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0 tmpfs /tmp tmpfs defaults,noatime,nosuid,size=100m 0 0 tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=30m 0 0 tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0 tmpfs /var/run tmpfs defaults,noatime,nosuid,mode=0755,size=2m 0 0 tmpfs /var/spool/mqueue tmpfs defaults,noatime,nosuid,mode=0700,gid=12,size=30m 0 0
I’m posting this with a caveat: I’m no Linux expert. But this, along with making the entire file system (save for a few special folders) read-only, allowed me to build a Raspberry Pi project which can be unplugged at any time while running without any file system corruption. I’ll be making a separate post on how to make the file system read-only in Raspbian very soon.
Recent Comments