Mount the root filesystem read-only with ro in fstab
List the root device with the ro option in /etc/fstab so an embedded board's root filesystem is mounted read-only, and a power cut cannot corrupt it.
A filesystem that is never written cannot be left half-written by a power loss, which is the reason many products ship with a read-only root. The fstab line is the one place that states it for the running system.
/dev/mmcblk0p2 / ext4 ro,noatime 0 1
/dev/mmcblk0p3 /data ext4 rw,noatime,sync 0 2mount | grep ' on / '/dev/mmcblk0p2 on / type ext4 (ro,noatime)The kernel mounts the root device before it reads fstab, using the command line, so add ro there too (root=/dev/mmcblk0p2 ro rootwait). A rw on the command line, which many boards set by default, gets the root mounted read-write first, and the fstab line is applied later by a remount, if your init does one. Check the output of mount, not the file. Services that write to /var or /etc will now fail with "Read-only file system", so give them a tmpfs or the writable data partition. Also note an ext4 journal needs a recovery pass after a power cut, and replaying it writes, so the first boot after a crash may mount read-write briefly. See the mount(8) option list.