54

I installed Linux Mint 12 KDE, and I would like to check the root partition for any errors.

How do I check the root partition with fsck at boot time?

6 Answers 6

68
sudo touch /forcefsck

Then reboot.

4
  • 1
    This works, but for whatever reason, systemd recommends to pass fsck.mode=force on the kernel command line instead. (A warning appears in journalctl -xb.) Jan 26, 2021 at 8:33
  • Did it for me (Debian 10). May 4, 2021 at 14:58
  • @SeppoEnarvi: the forcefsck is (was?) natively supported only by system V init, but neither upstart nor systemd. The support for it may be added by the distro (Debian and, therefore, Ubuntu, do). The solution you mention is distro-independent. Too bad it's not a simple business to pass anything on the kernel command line on a headless server or a cloud VM... May 4, 2021 at 15:17
  • 2
    This no longer works, fsck.mode=force is now required. askubuntu.com/a/1352782/293072
    – Alkanshel
    Mar 23, 2023 at 5:13
29

You can use shutdown command for this too.

shutdown -rF now

From man:

The -F flag means 'force fsck'.
This only creates an advisory file /forcefsck which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide to run fsck(1) with a special `force' flag so that even properly unmounted file systems get checked. After that, the boot process should remove /forcefsck.

3
6

Here is another way to do this:

tune2fs -C 2 -c 1 /dev/THEDEVTHATROOTIS

reboot

then the filesystem will be checked, and once all is good you should do

tune2fs -c 60 /dev/THEDEVTHATROOTIS

I have assumed that the max-mount-count was set to 60, you should find out before issuing the first command with

dumpe2fs /dev/THEDEVTHATROOTIS |grep "Maximum mount count"

2
  • 4
    your answer is good and ... should work most of the time (I mean on most of standard installed Linux) BUT, you ASSUME that root partition is ext2,3,4 formatted, what if is something else like xfs or reiserfs ? :) Sep 14, 2014 at 8:17
  • True this is a 9/10 solution.
    – g24l
    Jan 28, 2015 at 9:38
4

On my systems (several x86 notebooks and a Banana Pi Pro), saying sudo shutdown now brings me to runlevel 1 (aka maintenance mode) where I can safely check my root FS:

mount -o remount,ro /dev/rootpartition
fsck /dev/rootpartition
reboot

There's no need to alter /etc/fstab to do this, and I have the opportunity to run fsck with whatever options that may be needed to fix a tricky case.

Note: /forcefsck and tune2fs tricks work on x86, but not on Banana Pi.

3
  • It would be possible to make tune2fs etc work on any platform, given that a (possibly embedded) initramfs is supported. So it really just depends on the Linux distribution.
    – Daniel B
    Sep 16, 2015 at 18:12
  • Answer not working for remote checkings. Feb 20, 2016 at 13:47
  • @SopalajodeArrierez Yeah, you need access to a local terminal in single user mode, hence the name. Feb 22, 2016 at 11:02
0

On modern linux systems the answers above (with forcefsck) don’t work. You have to do it manually:

  1. Put your root partition into read-only mode by modifying the faulty partition’s line on /etc/fstab (but remember your old settings):

    UUID=fd1d0fad-3a4c-457f-9b5e-eed021cce3d1 /                       ext4    remount,ro        1 1
    
  2. Reboot

  3. Switch to runlevel 1 just to minimize the amount of interfering processes:

    init 1
    
  4. Fix your file system (replace /dev/sda2 with your partition’s device), which should now work because the root partition is in read only:

    fsck /dev/sda2
    
  5. Reboot. (On my Fedora 21 system I had to change to runlevel 1 during boot with Grub2, because otherwise the system was stuck due to not being able to write on the root-partition)

  6. Make your root file system readable/writable:

    mount -o remount,rw /dev/sda2
    
  7. Restore your /etc/fstab to its original state.

  8. Reboot


Source: http://bitsofmymind.com/2014/03/14/how-to-fix-fsck-your-root-file-system-that-you-have-to-boot-into-on-linux/

1
  • 4
    Could you please elaborate on these “modern Linux systems”, that are, in keeping with the question, Linux Mint?
    – Daniel B
    Sep 16, 2015 at 18:23
0

If you are on a Raspberry pi and you find yourself in emergency mode, you can in fact unmount the root partition and still use fsck

(login as root)
mount -o remount,ro /
fsck
reboot
1
  • 1
    mount point is busy, ubuntu20 Jun 18, 2021 at 12:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .