FSCK

====================================================================================
FSCK (File System Consistency Check)
------------------------------------------------------------------------------------------------------------------------------------------------
What does FSCK do?
fsck (file system consistency check) is a system utility used to check and repair filesystems. FSCK is made up of various tools that are made to handle different filesystem types, these are stored within /usr/sbin:
lrwxrwxrwx 1 root root         8 Mar 23  2022 dosfsck -> fsck.fat
-rwxr-xr-x 1 root root    360280 Jun  1  2022 e2fsck
-rwxr-xr-x 1 root root     43440 Apr  9 15:32 fsck
-rwxr-xr-x 1 root root      1185 Feb 24  2022 fsck.btrfs
-rwxr-xr-x 1 root root     31168 Apr  9 15:32 fsck.cramfs
lrwxrwxrwx 1 root root         6 Jun  1  2022 fsck.ext2 -> e2fsck
lrwxrwxrwx 1 root root         6 Jun  1  2022 fsck.ext3 -> e2fsck
lrwxrwxrwx 1 root root         6 Jun  1  2022 fsck.ext4 -> e2fsck
-rwxr-xr-x 1 root root     84360 Mar 23  2022 fsck.fat
-rwxr-xr-x 1 root root     55712 Apr  9 15:32 fsck.minix
lrwxrwxrwx 1 root root         8 Mar 23  2022 fsck.msdos -> fsck.fat
lrwxrwxrwx 1 root root         8 Mar 23  2022 fsck.vfat -> fsck.fat
-rwxr-xr-x 1 root root      1968 Feb  9  2022 fsck.xfs
-rwxr-xr-x 1 root root     51592 Nov  1  2022 ntfsclone
-rwxr-xr-x 1 root root     35200 Nov  1  2022 ntfscp
Purpose of fsck
Checking Filesystem Integrity: It scans the filesystem for inconsistencies and potential errors, such as corrupted metadata, lost clusters, and bad sectors.
Repairing Errors: 
fsck can fix detected issues to prevent data loss and improve system stability.
------------------------------------------------------------------------------------------------------------------------------------------------
You can only run a filesystem check on an unmounted disk.
Scanning a specific disk (optional repair):
fsck -t ext4 /dev/sda2
Scanning all disks (optional repair)
fsck -A
FSCK Options:
-A
Check all filesystems.
-t [option]
Specify filesystem type
-y
Automatically attempt to fix any errors without user prompt
-n
Do not attempt to repair
-f
Forces a check, even if the filesystem appears to be fine
-T 
Skip mounted filesystems
-R
Skip the root filesystem
------------------------------------------------------------------------------------------------------------------------------------------------
FSCK on boot
FSCK can be configured to run for each filesystem when the server boots. For more info see here.
====================================================================================