Greetings!
The use-case of a robot, especially an educational robot, involves frequent reboots and potential crashed filesystems.
The ext-4 filesystem is designed to be robust and - essentially - self-healing. However, that has its limitations. It’s self-healing capabilities only go so far and are no substitute for a thorough periodic fsck.
It is especially noteworthy that even the designers and toolsmiths for the ext filesystem recommend a periodic fsck.
The man page for tune2fs says this well:
and
Note that tune2fs can be safely used on a mounted filesystem.
As a standard thing, I set my filesystems as follows:
pi@GoPiGo:~ $ sudo tune2fs -c 5 -C 6 -i 5 -e remount-ro /dev/mmcblk0p2
tune2fs 1.44.5 (15-Dec-2018)
Setting maximal mount count to 5
Setting current mount count to 6
Setting error behavior to 2
Setting interval between checks to 432000 seconds
pi@GoPiGo:~ $
This does:
- (-c) sets the max mount counts before checking to five.
- (-C) sets the current mount count to six, forcing a fsck on the next reboot.
- (-i) Sets the number of days before forcing an fsck to five. This guarantees a thorough fsck at least once a week.
- (-e) Sets the error behavior to “remount read only” so that the filesystem can be removed from the robot and carefully fixed on another system while it is cold.
I then reboot to start the process going.
You can do other things like resetting the UUID, adding a label, setting the reserved sector count - which should be zero on an external data device like a flash-drive that isn’t a system device - etc.
Tune2fs is one of those lesser-known commands that, (IMHO), are as important as knowing man pages and being able to web search.