Corruption in ext4 root
Daniel Gröber
dxld at darkboxed.org
Wed Dec 16 16:41:07 EST 2020
Hi Michael,
On Tue, Dec 15, 2020 at 09:16:50PM -0600, W. Michael Petullo wrote:
> I often find the OpenWrt image's root filesystem corrupt after running
> "poweroff" and then restarting the DomU VM.
What exactly do you mean by "corrupt"? Are files that you create before the
poweroff just gone or does the kernel actually complain about errors in the
FS on the next boot?
If it's the former I might be able to help as I've had a similar problem:
what I found is that the mount_root command, which mounts the rootfs on
bootup, has logic that will wipe your entire overlay FS if there isn't a
.fs_state symlink in the overlay mountpoint containing the string "2".
See
https://git.openwrt.org/?p=project/fstools.git;a=blob;f=libfstools/overlay.c;h=eadafcf4391f36658c26f94c5fec770aeb6c743a;hb=HEAD#l438,
the fs_state_get() function reads the .fs_state link and the
overlay_delete() call deletes the overlay FS recursively.
Basically the solution in my case was to simply wait until
/etc/rc.d/S95done was run, as this runs `mount_root done` which will set
the .fs_state such that this doesn't happen on the next bootup.
--Daniel
PS: This hack took me a good two days to debug and frankly making fs_state
a hidden file just adds insult to injury.
More information about the openwrt-devel
mailing list