OS modifications for safe sudden power cuts

Hi everyone,

under: ROSbot 2.0 & ROSbot 2.0 PRO | Husarion, in the section “Software” it is stated that:

“The OS has been modified to make the file system insensitive to sudden power cuts.”

Could someone please explain what changes have been made? Maybe Overlay-FS or read-only SD card with writable USB-stick?

Until now, I’ve always properly shutdown my tinker board / Rosbot 2.0. Now I would like to just cut the power while in operation. I’m asking because I’m not really trusting the statement without knowing how it’s done.

Greetings
Hans

Hello Hans,

The system is installed on single microSD card which is divided into two partitions.
First partition is /boot which contains base system files used mainly during startup time. It is configured with option sync, this prevents data caching, thus writes to the device have to be done immediately.

Second partition, which is root filesystem and is set to be ext4, was configured with default value of commit=5, the documentation for ext4 explains:

Ext4 can be told to sync all its data and metadata every 'nrsec' seconds. The default value is 5 seconds. This means that if you lose your power, you will lose as much as the latest 5 seconds of work (your filesystem will not be damaged though, thanks to the journaling). This default value (or any low value) will hurt performance, but it's good for data-safety. Setting it to 0 will have the same effect as leaving it at the default (5 seconds). Setting it to very large values will improve performance.

Both partitions are configured with option noatime, this prevents saving access time to file when read, thus greatly reduce disk writes.

Full configuration is defined in /etc/fstab file:

/dev/mmcblk0p2 /     ext4  commit=5,noatime    0 1
/dev/mmcblk0p1 /boot vfat  sync,noatime        0 2

The above setup was proven to be power-down safe across multiple tests.

Regards,
Łukasz