FSCK is the utility to check the filesystems for errors or outstanding issues. The tool is used to fix potential errors and generate reports. The Utility comes by default with Linux distributions. Let’s see how to run fsck on Linux

There are multiple ways to do it. Let’s see all options
Option 1
Before running fsck on any partition, you need to make sure that the partition isn’t mounted.
To umount the partition run the command below.
# umount /dev/sdb
After you have unmounted the partition, you can directly run fsck on the partition, but I would recommend you to first dry run. The dry run will just show the errors and will not actually fix them
To do dry run fsck, use the command below.
fsck -N /dev/sdb1
after you have reviewed the files, then you can run the command below. – y option will make sure that you don’t get any prompts.
fsck -y /dev/sdb1
If are still not sure about -y then you can use the option -p which tells fsck to automatically repair any problems that can be safely fixed without user intervention.
fsck -p /dev/sdb1
Once the file system is repaired, mount the partition:
sudo mount /dev/sdb1
Option 2
There is another option to run fsck on the system is to do it at the reboot. It’s a simple option.
First create a file called, forcefsck in / partition.
touch /forcefsck
now reboot the system, it will run fsck when you reboot the system. After your system is rebooted make sure that /forcefsck file is deleted.
Option 3
How to run fsck using /etc/fstab
So basically, fstab is the option that tells the operating system what filesystem should be mounted at booted and what should be the configuration. You can also use it to tell it to run fsck on boot.
fstab contains entries such as below
# [File System] [Mount Point] [File System Type] [Options] [Dump] [PASS]
/dev/sda1 / ext4 defaults 0 1
/dev/sda2 /home ext4 defaults 0 2
0 – Do not check.
1 – The file systems are to be checked first and one at a time.
2 – All other file systems are checked later and possibly in parallel.
The root file system should have a value of 1, and all other file systems you want to be checked should have a value of 2.
I hope you now know how to run fsck on Linux