I'm running a Pine A64 with the fs on SD card (ext4, custom image). In case of power losses the fs gets corrupted what leads into booting/random reboots problems. E.g. "fsck" told me that an inode has changed.
I guess "ext4 + journal" would help but I often read it's not recommended because of performance issues.
What do you think? Any other options?
@markbirss Can I edit my /etc/config on a different pc with squashfs?
Refer to further instructions about squashfs to unpack and repack
Here is another bool todo some other nice tasks
How does squashfs avoid SD card corruption by power loss?
It mounts read-only as sated on
If it is read-only, where are your changes permanently saved?
Thank you, I will read through the links, but whats wrong with ext4+journal?
only at modification via a overlay
And the overlay resides... on the SD card?
How can it then be immune to SD card corruption?
would still be prone to corruption when changes are made
Thanks, that was my point.
@gueni If you want to avoid SD card corruption due to power loss, make sure that there is no power loss (e.g. UPS).
Here is another approach to adding spi flash to microsd
It case you missed this also
From the OpenWRT docs
Which image to chose?
Often, different images are available for a device. The differ in the filesystem used.
newer images include a hidden f2fs filesystem, which is optimized for flash memory
needs special mount procedure, to externally modify it
all changes are done in an overlay partition
Ext4 will cause more flash wear
It might be true on regular linux but is it true for OpenWrt what writes very little (if at all) to sd card? Journal should prevent data corruption on power loss, doesn't it?
Yes, it is possible but that is what exists in the OpenWRT documentation with regard to ext4 and squashfs.
I wounder how an inode can be corrupted on power loss if no changes made to the fs from the user. Does the kernel write to inodes regularly? Maybe it has nothing to do with the fs but with the SD card itself?
MIGHT be few writes from the active services. I.e. to update a time stamp of a file, to keep initial system time on next boot not too far off real time (unless you have battery backed Real Time Clock on your device). I do these writes explicitly, in a cron job, for years already. Quite possible, because of wireguard this has been automated, in the meantime. ext4+journal should fix your issue, correct. But then you might examine your files, first, which ones are modified and how often.
Thank you all for your input! I let it sink in.
I found that on raspi forum:
The problem of sd-cards that can corrupt themselves when turning power to them off suddenly isn't solvable by doing something with the PI.
The problem is that an sd-card contains a micro controller that independently performs tasks that cannot suddenly be aborted by failing to provide power to the card without risking storage corruption.
The micro controller independently from the main system shuffles data around, and interrupting such shuffling (by pulling the power) leads to the micro controller losing track of where some data is actually stored.
In fact because any filing system that uses the sd-card will write to sections containing such things as directories and file allocation table, the most often, the micro controller most likely shuffles just that kind of data around, so losing that data is most likely to be fatal for the filing system.
It is all because sd-cards use flash memory that can only endure limited amounts of write cycles, so the micro controller is constantly busy copying flash sectors that have been written to too many times to sectors that are "fresh".
So on SD cards it's probably "hopeless" and
@tmomas is right with his statement:
Since on my last build the "poweroff" command it's working now the issue is small cause I don't have to pull the plug while running...