How to run e2fsck with overlayfs

Hi there,

I am looking for a way to checking overlayfs. I tried to umount the partition invoke with overlayfs but failed.
the system always show partition is in use.

Please help me with this.

Thanks

I haven't tried it, but try remounting the partition as read-only.

1 Like

I noted your question on boot-time fsck in another thread. You probably could hook the boot() function in /etc/rc.d/S10boot to accomplish that.

There's a little Catch-22 there though, as you'll likely need to have the modified script and utilities such as e2fsck in the root file system as the overlayfs won't have been mounted yet.

1 Like

Do you mean run e2fsck /dev/overlay_partition before mount_root??

I am failed to remount overlay with ro mode.

If logged in as root, you won't need sudo -- you may need to unmount the overlayfs entirely, and remount your equivalent of /dev/mtdblock3, but the "standard" method of changing a mount to readonly seems to work as expected.

jeff@office:~$ sudo mount -o ro,remount overlayfs:/overlay
jeff@office:~$ mount
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/mtdblock3 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlay (ro,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
2 Likes

Hi jeff,

Thanks for your solution, I will try it.
I also finding away to run e2fsck by creating a boot hook script in /lib/preinit/, and put it run before 80_do_mount_root was run.
Now every time I reboot/powercycle, overlayfs is checked by e2fsck.

Thanks

Tuan Nguyen

Can you tell more about how you've check at preinit ? thanks in advance