fsck stands for "file system check" and it is used to check and optionally repair one or more Linux file systems. Normally, the fsck program will try to handle filesystems on different physical disk drives in parallel to reduce the total amount of time needed to check all of the filesystems (see: man fsck).

The Arch Linux boot process conveniently takes care of the fsck procedure for you and will check all relevant partitions on your drive(s) automatically on every boot. Hence, there is usually no need to resort to the command-line unless necessary.

Contents

Check Now

To check all the relevant partitions immediately, run:

# shutdown -Fr now

The command shutdown brings down the system in a secure manner, -F forces fsck to be safely invoked on a reboot, -r causes the system to reboot after shutdown, and now shuts down the system immediately.

Check Later

Another method would be to create a forcefsck file on the partition you wish to check later. For example, for the root partition it would be:

# touch /forcefsck

When you're ready, reboot and fsck will do the rest. And don't worry, this file will be removed automatically when the process is finished.

Other fsck tricks

A list of all available options can be found by running:

# fsck -h

To automatically repair damaged portions, run:

Warning: This will not ask if you want to repair it, as the answer is Yes when you run it.

# fsck -a

To make no changes to the filesystem (opposite of the above, meaning the answer is No when asked about fixing errors), run:

# fsck -n

Changing check frequency

By default, fsck checks a filesystem every 30 boots (counted individually for each partition). To change the frequency of checking, run:

# tune2fs -c 20 /dev/sda1

In this example, 20 is the number of boots between two checks.

Note that 1 would make it scan at every boot, while 0 would stop scanning altogether.

Tip: If you wish to see the frequency number and the current mount count for a specific partition, use:

# dumpe2fs -h /dev/sda1 | grep -i 'mount count'

fstab options

fstab is a system configuration file and is used to tell the Linux kernel which partitions (file systems) to mount and where on the file system tree.

1 = First file system (partition) to check; / (root partition) should be set to 1.

2 = All other filesystems to be checked.

Troubleshooting

Can't run fsck on a separate /usr partition

Make sure you have the required hooks in /etc/mkinitcpio.conf and that you remembered to re-generate your initramfs image after editing this file.

Make sure that the bootloader has ro on the "APPEND" line in /boot/syslinux/syslinux.cfg (for Syslinux). GRUB doesn't need one; it is added automatically when you generate a .cfg. For an explanation as to why you need "ro", see this post.

Check your fstab! Only the root partition needs "1" at the end, everything else should have either "2" or "0". Carefully inspect it for other typos, as well.