Linux File System Management Tools - fsck command

The Linux fsck command analyzes the specified filesystem and performs repairs as required. For example, if you have problems in your Linux machine with files in the /home1 directory, which is mounted on /dev/sdb1, then execute the following "fsck" command for a file system to check it and repair. Make sure to unmount the file system before running fsck.

[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 14G 2.3G 11G 18% /
/dev/sda1 99M 9.9M 84M 11% /boot
tmpfs 252M 0 252M 0% /dev/shm
/dev/sdb1 7.9G 147M 7.4G 2% /home1

[[email protected] ~]# umount /dev/sdb1

[[email protected] ~]# fsck -t ext3 /dev/sdb1
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
/dev/sdb1: clean, 11/1048576 files, 70321/2096474 blocks

Important options of Linux fsck command are

• -a option: Automatically repair the file system without any questions.

• -r option: Interactively repair the filesystem (ask for confirmations).

Other options of Linux fsck command are

• -A option: Walk through the /etc/fstab file and try to check all filesystems in one run. This option is typically used from the /etc/rc system initialization file, instead of multiple commands for checking a single file system.

• -R option: When checking all filesystems with the -A flag, skip the root file system (in case it’s already mounted read-write).

• -T option: Don’t show the title on startup.

• -N option: Don’t execute; just show what would be done.

• -s option: Serialize fsck operations.

• -V option: Produce verbose output, including all filesystem-specific commands that are executed.

Related Tutorials
• Linux File System Management Tools - fdisk command
• Linux File System Management Tools - mkfs, mkfs.ext2, mkfs.ext3 commands
• What is file system journaling?
• Introduction to Linux /etc/fstab file
• Linux mount and umount commands
• Linux mount options