How to Force fsck on Reboot
Fsck command is used to check filesystem consistency in Linux and Unix-like operating systems. On the system, fsck runs either automatically or manually. The filesystem shouldn't be mounted while running the fsck. We can force fsck to run on reboot for both root and non-root filesystems.
For systemd to perform single time force fsck during the boot:
Boot to the Grub menu
While entry is highlighted, press 'e' to edit the commands
Press "End" button to move cursor to the last
Add a space and then add the kernel parameter fsck.mode=force
Press Ctrl + x to close and boot the system
Perform fsk on every boot
For systemd-based Linux distributions, add fsck.mode=force to your grub configuration file as a kernel parameter. It's important to note that systemd-fsck doesn't know anything about the filesystem, so it just runs file system checkers specific to each filesystem type (/sbin/fsck.*). If you have an ext4 filesystem, for example, systemd-fsck will run /sbin/fsck.ext4.
You need to add fsck.mode=force to GRUB_CMDLINE_LINUX_DEFAULT, at the end of the last quote (").
Example:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash fsck.mode=force"
If you want to automatically repair problems that are easily fixed, you can add the option fsck.repair=yes to the grub configuration file. The yes in fsck.repair indicates that the system accepts "yes" as an answer to all fsck questions
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash fsck.mode=force fsck.repair=yes"
You can edit the grub configuration using the nano command.
sudo nano /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD …)
# GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
# GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
# GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
# GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
# GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
# GRUB_INIT_TUNE="480 440 1"
Make sure that you do not make any additional changes and the changes you made are correct, or your system will fail to boot. After you have made the changes, you can save the nano file and exit.
After you've finished editing and saved your file, run the following command to update the Grub2 configuration.
sudo update-grub
You must now reboot the system, and fsck will perform a filesystem consistency check on every boot.