When the system starts throwing errors about the main filesystem, it’s time for a check. fsck handles the file system check.

Warning

While a file system check shouldn’t loose any data, it’s possible to loose ALL your data. Especially if there’s an actually issue with the filesystem. Make sure you have a backup.

Systemd

To force check the system in systemd, add the below to your kernel options. This is the linux line in grub which can be edited by pressing e (for ’edit’) on the selected system when the system shows the selection of operation systems in grub.

fsck.mode=force

So it looks something like:

  linux   /vmlinuz-linux root=.....  quiet fsck.mode=force
  initrd  /initramfs-linux.img

This will run the fsck automatically. If there is anything that the system needs you attention for, it will drop you to a shell where you can run it manually.

Traditional SysVinit

With the traditional SysVinit system, you would create a file in the root (/) of the system named forcefsck.

touch /forcefsck

Systemd

It’s also possible to boot into Single User Mode by adding the below to the kernel line:

systemd.unit=rescue

(On traditional systems, add init 1)

This will give you a prompt. Typically, we will want to run something like this, where /dev/sdX is the path to our hard drive.

fsck -C0 /dev/sdX