I am working with embedded Linux build with Yocto. My goal is to enforce file checking during each system booting. I've modified the /etc/default/rcS file and I've set ENABLE_ROOTFS_FSCK=yes and FSCKFIX=yes. fsck tries to check a rootfs but I get the following error:
e2fsck 1.46.2 (28-Feb-2021)
fsck.ext2: No such file or directory while trying to open /dev/root
Possibly non-existent device?
fsck failed. Please repair manually and reboot. Please note that the root filesystem is currently mounted read-only. To remount it read-write:
# mount -n -o remount,rw /
CONTROL-D will exit from this shell and REBOOT the system.
I see two problems here. First, why e2fsck cannot check the file system? Second, why e2fsck calls fsck.ext2 to check the ext4 filesystem? When I use fsck -n <partition> after normal boot, it works fine. I get the following log:
e2fsck 1.46.2 (28-Feb-2021)
Warning! <partition> is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
<partition> clean
Thank you in advanced for any help.
EDIT: I use Linux built with Yocto with kernel 3.18 and systemVinit. There are some more methods to force fsck during boot process but they seem to work on systems with systemd. I suppose that e2fsck doesn't know which partition it should check. It tries to check /dev/root instead of my physical partition /dev/mmcblk0p2.