Checking the file system for errors is an important part of Linux system administration. It is a good troubleshooting step to perform when encountering bad performance on read and write times, or file system errors. In this tutorial, we will explain a procedure on how to force fsck to perform a file system check on the next system reboot or force file system check for any desired number of system reboots, whether it is the root or a non-root mount point.
In this tutorial you will learn:
- How to view when a file system was last checked by
fsck
- How to view and modify PASS value in
/etc/fstab
file - How to force fsck for root and non-root partitions

Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux system |
Software | tune2fs |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
View when a file system was last checked by fsck
Let’s start with discussion about some tools which can be used to obtain filesystem information and configurations which control file system check after system reboot. The tool which we are going to discuss is
tune2fs
filesystem managing utility. Using tune2fs
we can export some important information related to file system health check.
- The following Linux command will tell us when was the last time the file system
/dev/sdX
was checked:$ sudo tune2fs -l /dev/sdX | grep Last\ c Last checked: Thu May 12 20:28:34 2022
- Another useful piece of information which can be retrieved by the
tune2fs
command relates to how many times our/dev/sdX
filesystem was mounted:$ sudo tune2fs -l /dev/sdX | grep Mount Mount count: 157
- Snd lastly how many mounts are allowed to pass before filesystem check is forced:
$ sudo tune2fs -l /dev/sdX | grep Max Maximum mount count: -1
From the above outputs we can establish the following information summary. The /dev/sdX filesystem was last checked on Thu May 12 20:28:34 2022
. Since the last check, this filesystem was mounted 157
times and maximum amount of mounts before next filesystem fsck check. In the above case the value -1
means that fsck is disabled.
View and modify PASS value in /etc/fstab
Now that we have learned about some
tune2fs
basics, let’s discuss PASS
system configuration option found inside of the /etc/fstab
file containing all on boot mountable partitions and their relevant mount options.
First, use the blkid
command to figure out the UUID value of the file system you want to check.
$ blkid /dev/sda3 /dev/sda3: UUID="c020d4d8-c104-4140-aafc-24f7f89f8629" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="22ada8f4-5222-4049-b0fe-a3274516754d"
Then, grep
for that UUID in the /etc/fstab
file.
$ grep c020d4d8-c104-4140-aafc-24f7f89f8629 /etc/fstab UUID=c020d4d8-c104-4140-aafc-24f7f89f8629 / ext4 errors=remount-ro 0 0
The last column, which is column number 6, is the fsck PASS column. This is used by fsck to determine whether fsck should check the filesystem before it is mounted and in which order the given partitions in /etc/fstab
should be checked. Possible entries for fstab PASS column are 0, 1 and 2. Here is what each number means.
0
– disabled, that is do not check filesystem1
– partition with this PASS value has a higher priority and is checked first. This value is usually set to the root/
partition2
– partitions with this PASS value will be checked last
The connection between fstab PASS value, last checked value, and number of mounts value is as follows:
During the system boot, the first value which is checked is fstab PASS value. If this value is 0, then no other values are checked and fsck will NOT perform filesystem check. However, if the PASS value found in /etc/fstab
is any other than 0, that is 1 or 2, then values of maximum mounts and total mounts are checked.
If the value of maximum mounts is greater or equal to total number of mounts value then fsck’s filesytem check will be performed. Few examples:
FSCK DISABLED fstab PASS: 1 Maximum mount count: -1 Mount count: 157 ---- FSCK DISABLED fstab PASS: 0 Maximum mount count: -1 Mount count: 157 ---- FSCK ON NEXT REBOOT fstab PASS: 1 or 2 Maximum mount count: 1 Mount count: 157 ---- FSCK DISABLED fstab PASS: 0 Maximum mount count: 1 Mount count: 1 ---- FSCK ON NEXT REBOOT fstab PASS: 1 or 2 Maximum mount count: 1 Mount count: 1 ---- NO FSCK ON NEXT REBOOT fstab PASS: 1 or 2 Maximum mount count: 200 Mount count: 157
Force fsck for root or non-root partitions
To force filesystem check on a partition, we must first change fsck’s PASS value in
/etc/fstab
to value 2
. For example:
UUID=c6e22f63-e63c-40ed-bf9b-bb4a10f2db66 /mnt ext4 errors=remount-ro 0 2
After this change has been made, see the command examples below to finish forcing fsck to run.
- To ensure that your file system is checked on the next reboot, we need to manipulate the filesystem’s “Maximum mount count” parameter. The following
tune2fs
command will ensure that filesystem/dev/sdX
is checked every time your Linux system reboots. Please note that for this to happen the fsck’s PASS value in/etc/fstab
must be set to a positive integer as discussed above.$ sudo tune2fs -c 1 /dev/sdX
Note that this will continue to force fsck after every system reboot until you revert the setting.
- Alternatively we can set fsck after every 10 reboots:
$ sudo tune2fs -c 10 /dev/sdX
- Or to disable the setting, use the value
-1
.$ sudo tune2fs -c -1 /dev/sdX OR $ sudo tune2fs -c 0 /dev/sdX
Closing Thoughts
In this tutorial, we saw how to force fsck to check the file system of a root or non root partition on a Linux system. This can be achieved by making the necessary edits to the /etc/fstab
file, along with using the tune2fs
command. It is recommended to let fsck occasionally check your file system for errors, which can alert you of hardware failure, increase performance, and minimize the likelihood of data loss.