Manual Fsck

In actuality, fsck is simply a front-end for the various filesystem checkers ( fsck. Fstype) available under Linux. The filesystem-specific checker is searched for in the PATH environment variable. If the PATH is undefined then fallback to /sbin. Please see the filesystem-specific checker manual pages for further details. Failure: File system check of the root filesystem failed The root filesystem on /dev/sda5 requires a manual fsck BusyBox v1.30.1 (Ubuntu 1:1.30.1-4ubuntu6.3) built-in shell (ash) Enter 'help' for a list of built-in commands. I executed the following command and accepted all its 'y' which had as default in each message: fsck /dev/sda5. FSCK.FAT(8) System Manager's Manual FSCK.FAT(8) NAME top fsck.fat - check and repair MS-DOS FAT filesystems SYNOPSIS top fsck.fat OPTIONS DEVICE DESCRIPTION top fsck.fat verifies the consistency of MS-DOS filesystems and optionally tries to repair them. The following filesystem problems can be corrected (in this order):. FAT contains. Automatically answer yes to all fsck questions. When filesystem errors prevent a reboot, you are instructed to run fsck on the affected filesystem. If there are lots of errors, you may be stuck typing y for hours. An option to fsck can automatically answer yes for you. Warning: Use this at your own risk.

Performing fsck on non-root filesystem is fairly straight forward. But, for root filesytem, you cannot perform fsck when it is mounted.

This quick tutorial explains how to force filesytem check for a root filesystem.

Root Filesystem

In this example, /dev/sda1 partition is the root filesystem that is mounted as /

If you run a fsck to check your root filesystem, you’ll get the following error message, as /dev/sda1 is mounted, and your cannot perform fsck on a mounted filesystem.

If you are performing a fsck on a non-root file system, you can just unmount that partition and perform fsck.

But in this case, we like to perform fsck on a root filesystem. So, what is the solution?

Also, if you are new to fsck, refer to this: 10 Linux Fsck Command Examples to Check and Repair Filesystem

Tune2fs Output Before Reboot

Before we reboot the system, let us check when was the last time fsck performed a check on the root filesystem.

Ubuntu Manual Fsck

For this, use tune2fs command, and grep for “check” as shown below.

As we see from the above output:

  • Last checked: indicates the last time the root filesystem check happened. This happened on Nov.
  • Check internal: indicates how often the root filesystem will be checked. In this example, it will wait for another 6 months before fsck will be executed on this filesystem during reboot.
  • Next check after: indicates the date and time after which when you perform a reboot, the filesystem will be checked. This will happen only after May.

But, in our case, we don’t want to wait until May. We want to perform root filesystem fsck check now.

Create /forcefsck File to Force Check Root Filesystem

So, to force a root filesystem check, one of the easy way is to reboot the system, and force fsck to perform the filesystem when the system is starting up before the root filesystem is mounted by the kernel.

To force the fsck during reboot, first create an empty file called forcefsck under / as shown below.

Now reboot the system:

Tune2fs Output After Reboot

If you have console access, you can see that fsck will be performing the check on the / filesystem during the reboot.

How To Perform A Manual Fsck

After the check, fsck will automatically delete the /forcefsck file that we created earlier. After the reboot, you won’t see this file anymore.

File

Now, if you execute tune2fs, you’ll see the “Last checked” field was updated with the current timestamp. This confirms that fsck performed the root filesystem check during the reboot.

Linux Mint Manual Fsck

You’ll also see the value of “Next check after” changed accordingly. i.e 6 months from the time we rebooted the system.