I'm going to be embedding Ubuntu on an embedded device. I'm using a combination of aufs and a read only root to ensure that my root fs doesn't get corrupt. However, I want to be able to store logs, so I'm making a special rw partition for /var/log
. The device is going to undergo hundreds of power failure events.
In the event that the partition gets corrupted due to power failure, I want the system to work properly anyway. I'd like the partition to automatically get reformatted in case of corruption. Is there an easy way to configure this?
Run
fsck
with a set of options that specify no user interaction. Test its return value to see whether it could repair the filesystem: the return value will be 0 if there were no errors, 1 if there were correctable errors, and a larger value if something bad happened. For example, with ext[234], rune2fsck -p
.If your running environment permits it, consider logging through the network instead (you need IP connectivity). Even Busybox can do it:
On the log server, listen on UDP port 514. You can just dump everything that comes in to a file, or you can add origin and date stamps on each line, or you can run syslog locally.
Just use a filesystem that does not get corrupted from power failures, like ext3 or 4.