One thing you can do to engrave this in cast titanium is to take the fully built and running SD card and mount it on the Linux distribution of your choice. (I use a bootable CD/flash-drive of Linux Mint.)
Once mounted, run Gparted to find the SD card, identify its device name, (something like /dev/sda, /dev/sdb, etc.), and note the partitions on it. (/dev/sda1, /dev/sda2, or whatever they are on your system.)
Look to see if the partitions are formatted as “ext” type partitions.
Note: Tune2fs ONLY works on “ext” formatted partitions. FAT, FAT-32, NTFS, etc., won’t work.
For every “ext” formatted partition, one at a time, run tune2fs as root, or use sudo.
tune2fs -l /dev/sda1
(replace the device and partition with whatever is on your system), will list all the current file-system attributes for that particular partition.
The ones you are most interested in are “maximum mount count”, “interval between checks” and “mount count”
You want to set “interval between checks” to something reasonable, based on your usage scenario - I set my robot to “10”- every ten days it checks the partition if it hasn’t been checked before then.
You set “maximum mount count” to something reasonable. I set my 'bot to “5” - every five reboots, it checks the partition.
Set “mount count” to some number greater than the max mount count. This will force a fsck, (checkdisk), immediately when the device is rebooted.
Do this for every partition, even if it is normally read-only.
Set the interval between checks to slightly different values for each partition to prevent every partition from fsck’ing all at once, (except for the first reboot after these settings are set).
You can, and possibly should, set the error behavior to something like “remount read-only” to prevent your file system from being trashed if it discovers an unfixable error on boot.
Assume your SD card (in a USB adapter) is located at /dev/sdc. Also assume that there are two ext-3/ext-4 partitions located at /dev/sdc1 and /dev/sdc2.
tune2fs -c 7 -i 5 -C 8 -e remount-ro /dev/sdc1
. . . will set the first partition on /dev/sdc to:
- Automatically check every seventh time the partition is mounted, typically seven reboots.
- Automatically check the partition every fifth day if it hasn’t been rebooted seven times before then. (Assuming that the system is rebooted less often than seven times within those five days.)
- Sets the “number of times it has been mounted” to “8” (which is larger than seven, so it will check itself on the very next reboot).
- If the system detects a filesystem error, it will re-mount the partition as read-only, regardless of what it would normally do.
I set my 'bot to really short values because I reboot it a lot, occasionally kill battery power accidentally, run untested software I am working on, and other similarly evil things. My desktop/laptop systems are set to much larger values like every 27 days, 21 mounts, or something like that.
You will have to decide what is reasonably conservative, (more often is better than less, you can always change it later), based onyour needs.
In any event, “tune2fs” is a good trick to know to help keep your file systems happy.