Checking disks and filesystems for errors
Linux filesystems are incredibly robust. Despite that, a filesystem can become corrupted and data can be lost. The sooner you find a problem, the less data loss and corruption you need to worry about.
Getting ready
The standard tool for checking filesystems is fsck
. This command is installed on all modern distributions. Note that you'll need to run fsck
as root or via a sudo
.
How to do it...
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...