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: ).
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.
- 1 Boot time checking
- 2 Tips and tricks
- 3 Troubleshooting
Boot time checking
There are two players involved:
- mkinitcpio offers you the option to fsck your root filesystem before mounting it via the fsck hook. If you do this, you should mount root read-write via the appropriate
- systemd will fsck all filesystems having a fsck pass number greater than 0 (either from
/etc/fstabor a user-supplied unit file). For the root filesystem, it also has to be mounted read-only initially with the kernel parameter
roand only then remounted read-write from fstab (note that the
defaultsmount option implies
The first option is the recommended default, and what you will end up with if you follow the Installation guide. If you want to go with option 2 instead, you should remove the fsck hook from
mkinitcpio.conf and use
ro on the kernel commandline. The kernel parameter
fsck.mode=skip can be used to make sure fsck is disabled entirely for both options.
Forcing the check
Alternatively, systemd provides, which checks all configured file systems, which were not checked in the initramfs. However, checking the root filesystem this way causes a delay in the boot process, because the file system has to be remounted.
Tips and tricks
Attempt to repair damaged blocks
To automatically repair damaged portions, run:
# fsck -a
Repair damaged blocks interactively
To repair damaged portions, run :
# fsck -r <drive>
Changing the 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.
1 would make it scan at every boot, while
0 would stop scanning altogether.
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.
/etc/fstab entry may look like this:
/dev/sda1 / ext4 defaults 0 1 /dev/sda2 /other ext4 defaults 0 2 /dev/sda3 /win ntfs-3g defaults 0 0
The 6th column (in bold) is the fsck option.
- 0 = Do not check.
- 1 = First file system (partition) to check;
/(root partition) should be set to 1.
- 2 = All other filesystems to be checked.
Can't run fsck on a separate /usr partition
- Make sure you have the required hooks in
/etc/mkinitcpio.confand that you remembered to re-generate your initramfs image after editing this file.
- 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.
ext2fs : no external journal
There are times (due to power failure) in which an ext(3/4) file system can corrupt beyond normal repair. Normally, there will be a prompt from fsck indicating that it cannot find an external journal. In this case, run the following commands:
Unmount the partition based on its directory
# umount <directory>
Write a new journal to the partition
# tune2fs -j /dev/<partition>
Run an fsck to repair the partition
# fsck -p /dev/<partition>