How to Check and Repair a Filesystem with FSCK

It may look similar to a dirty word, but we can assure you that fsck is a tool that can make your dedicated server’s filesystem squeaky clean. With this easy command, you can check for errors and fix them.

To begin you will need to access your server’s command line interface. You can use SSH to remotely connect.

Next, you need to find out which volumes are currently mounted on your system:


The output may look something like this:

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sdb2 479041680 278982324 176080044 62% /

udev 1994212 4 1994208 1% /dev

tmpfs 802700 972 801728 1% /run

none 5120 0 5120 0% /run/lock

none 2006748 3036 2003712 1% /run/shm

cgroup 2006748 0 2006748 0% /sys/fs/cgroup

Before proceeding you should stop any services accessing the volume you want to check and unmount it. This obviously may not be possible with your main system volume. In such a case, you can tell fsck to check on the next reboot.

To run a check on /dev/sdb2, you would type:

fsck -v /dev/sdb2

To force fsck to check at the next reboot, you can create a file as root that will force it on the next boot:

touch /forcefsck

For more information about fsck and its many options, see the online documentation.