Linux Commands

How to Use FSCK in Linux to Check the File System?

“FSCK is a helpful Linux utility that can be used for checking the consistency and health of a file system. By using this tool, you can easily figure out all the potential issues with any of your file systems. In this guide, we will explain to you the method of using the FSCK command in Linux Mint 21 for checking a file system.”

Using the FSCK Command to Check the File System in Linux Mint 21

The FSCK command in Linux Mint 21 can be used to check the health of a file system in the following manner:

Step # 1: Display All the Mounted File Systems

First, you need to begin with displaying all the file systems that are mounted on your system with the command shown below:

$ df –h

All the mounted file systems of our Linux Mint 21 machine are shown in the following image. Here, we have highlighted the file system that we are going to check with the help of the FSCK command in this method.

Step # 2: Check the Partitions of the Target File System

After that, you can also find out all the partitions of the chosen file system so that you can figure out the exact partition that you wish to check. For doing that, you can run the command shown below:

$ sudo parted /dev/sda3 ‘print’

Here, you have to replace “/dev/sda3” with the particular file system that you have chosen.

From the output of this command, we have figured out that our chosen file system only has one partition, which is highlighted in the following image:

Step # 3: Unmount the Target File System

Now, before proceeding with the execution of the FSCK command in Linux Mint 21, you need to unmount the file system that you want to check. Otherwise, you will not be able to execute this command. To unmount the selected file system, you can run the command shown below:

$ sudo umount /dev/sda3

Step # 4: Run the FSCK Command on the Target File System

After unmounting the selected file system, you can run the FSCK command on it to check its health and consistency in the following manner:

sudo fsck /dev/sda3

Step # 5: Mount the Target File System Again

Once you have checked the health and consistency of your desired file system with the FSCK command, do not forget to mount that file system again by running the command shown below:

$ sudo mount /dev/sda3

Bonus Tip

If you feel hesitant before running the FSCK command on your Linux Mint 21 system, then you can even perform a test run by executing the following command:

$ sudo fsck –N /dev/sda3

This test run will not actually execute the FSCK command but will only predict the possible output of the FSCK command, as shown in the image below:

Conclusion

By using the FSCK command, as explained in this guide, you can quickly figure out all the issues with any given file system within your Linux Mint 21 system. Hence, it will be easier for you to resolve those issues well in time to avoid any inconvenient situations in the future.

Similar Posts