How to Force a Filesystem Check on Linux Root Partition (forcefsck)
This tutorial explains why running fsck on a mounted root filesystem fails, shows how to inspect the last check time with tune2fs, and provides step‑by‑step commands to create a forcefsck file, reboot, and verify that the root filesystem check was performed.
Root Filesystem
In this example /dev/sda1 is the root filesystem mounted as /.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 63G 41G 19G 69% /Running fsck /dev/sda1 on a mounted root filesystem fails with an error because the filesystem is in use.
# fsck /dev/sda1
fsck from util-linux-ng 2.17.2
e2fsck 1.41.12 (17-May-2010)
/dev/sda1 is mounted.
e2fsck: Cannot continue, aborting.For non‑root filesystems you can simply unmount the partition and run fsck. To force a check on the root filesystem, we use tune2fs to see when it was last checked.
tune2fs output before reboot
# tune2fs -l /dev/sda1 | grep -i check
Last checked: Mon Nov 24 12:39:44 2015
Check interval: 15552000 (6 months)
Next check after: Sun May 22 13:39:44 2016The output shows the last check date, the interval, and the next scheduled check.
Create /forcefsck to force a root check
Create an empty file named forcefsck in the root directory, then reboot.
# cd /
# touch forcefsck
# ls -l /forcefsck
-rw-r--r-- 1 root root 0 Mar 9 20:15 /forcefsck # reboottune2fs output after reboot
After reboot, fsck runs on the root filesystem and the forcefsck file is removed.
# ls -l /forcefsck
ls: cannot access /forcefsck: No such file or directory # tune2fs -l /dev/sda1 | grep -i check
Last checked: Wed Mar 09 20:30:04 2016
Check interval: 15552000 (6 months)
Next check after: Mon Sep 05 21:30:04 2016This confirms that the forced filesystem check was performed and the schedule has been updated.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
