I am working with embedded Linux build with Yocto. My goal is to enforce file checking during each system booting. So far I did the following steps:

  1. I've modified the /etc/default/rcS file and I've set ENABLE_ROOTFS_FSCK=yes and FSCKFIX=yes.
  2. I've used this command tune2fs -c 1 <my_fs> to check my fs during each booting.

I see the following log

`EXT4-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsck is recommended`

before mounting the root partition, but fsck is trying to check the partition just after it was mounted. So the process is aborted. The log:

mount: / is busy
*** ERROR!  Cannot fsck root fs because it is not mounted read-only!

How can I enforce fsck to check the file system before mounting the partition? Thank you in advanced for any help.


2 Answers 2


I may misunderstand your question, but:

There is no need to run tune2fs to run fsck. As you are not "tuning" any fs parameters, using tune2fs as a proxy for fsck simply adds overhead & may slow the boot process by a small amount.

Perhaps you meant e2fsck? fsck serves as a "wrapper" or "front-end" to provide legacy support. Typically, fsck simply calls e2fsck to do the real work.

Anyway - on to an answer:

I think fsck invocation can vary between OSs. One of my "embedded Linux" OS is RPi, and there are two methods for invoking fsck at boot time before the root filesystem is mounted:

  1. create a file named forcefsck in the root of the filesystem /; i.e.

    $ sudo touch /forcefsck

    This may have to be done before each boot - my OS deletes this file during boot

  2. use your editor to add the following to /boot/cmdline.txt:


    $ nano /boot/cmdline.txt

    console=serial0,115200 console=tty1 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

    console=serial0,115200 console=tty1 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.mode=force fsck.repair=yes rootwait

Again, I think this is OS-dependent, so YMMV.

  • $ sudo touch /forcefsck causes no effects. Parameter fsck.mode seems to be used by systemd, based on this link: man7.org/linux/man-pages/man7/kernel-command-line.7.html but my Linux distro uses systemVinit. Apr 16, 2021 at 7:45
  • @user1029384756: Sorry about that... figured to be a long shot, but thought it worth a try. I've nothing else to offer as I don't know Yocto. Good luck :)
    – Seamus
    Apr 17, 2021 at 5:40

You need an initram file system to do that. Check the real root file system before you switch to the real root.

Once a file system is mounted, it can't (should not) be modified, and you can't unmount the root fs.

  • Once a file system is mounted, it can't (should not) be modified, and you can't unmount the root fs. - this is simply not true. Apr 15, 2021 at 11:28
  • @ArtemS.Tashkinov which part? Should not be modified by fsck, or can't unmount while it is root? Yes, you can switch to another root and back, but it's more effort, and then it is not root while you check it.
    – RalfFriedl
    Apr 15, 2021 at 12:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .