To hopefully prevent filesystem corruption I've setup the /boot and / partitions as read-only. For some use cases I still need a writeable partition to store data. If plan to create a 3rd partition on the SD card and mount it at /rw. Does having a writable partition on the SD card reduce or eliminate the benefits of having the /boot and / partitions read-only? Like is there a chance that a power loss while writing to the 3rd partition will corrupt the whole SD card?
2 Answers
For an embedded project of mine, I use ro boot and rootfs, and two rw btrfs mirror raid partitions. I can cut power at anytime I need to, and my device can boot as the boot and root part are not modified. I chose btrfs as it has copy-on-write feature, with synchornization and snashots.
The risk damage due to power loss is greatly exaggerated.
Over 7 years using 9 Pi I have never experienced filesystem corruption due to power loss, although failed upgrades, user error and 2 worn out SD Cards have caused problems.
Attempting to have RO partitions is unlikely to help. The mapping between partition and physical storage is under the control of the SD Card firmware, so there is no guarantee of contiguous storage, and is managed transparently to the OS.
Having partitions on proper Erase Block Boundaries (and not all images do this correctly) may minimise the chance of loss, there is no guarantee that wear levelling will not change actual storage mapping. As the firmware is proprietary it is impossible to know what it does.
-
If you had over 6,000 devices you'd see it. How do you ensure that partitions are on proper Erase Block Boundaries Commented Sep 10, 2021 at 18:16