Linux will run fsck automatically at boot time if the filesystem has been unchecked for a long time or there is a reason (unsafe reboot after a power glitch) to suspect it's been corrupted. You can run fsck manually.
- To check for errors on a partition or filesystem, pass the path to fsck:
# fsck /dev/sdb3
fsck from util-linux 2.20.1
e2fsck 1.42.5 (29-Jul-2012)
HDD2 has been mounted 26 times without being checked, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
HDD2: 75540/16138240 files (0.7% non-contiguous),
48756390/64529088 blocks
- The -A flag checks all the filesystems configured in /etc/fstab:
# fsck -A
This will go through the /etc/fstab file, checking each filesystem. The fstab file defines the mapping between physical disk partitions and mount points. It's used to mount filesystems during boot.
- The -a option instructs fsck to automatically attempt to fix errors, instead of interactively asking us whether or not to repair them. Use this option with caution:
# fsck -a /dev/sda2
- The -N option simulates the actions fsck will perform:
# fsck -AN
fsck from util-linux 2.20.1
[/sbin/fsck.ext4 (1) -- /] fsck.ext4 /dev/sda8
[/sbin/fsck.ext4 (1) -- /home] fsck.ext4 /dev/sda7
[/sbin/fsck.ext3 (1) -- /media/Data] fsck.ext3 /dev/sda6