12

I have FSCKFIX=yes in /etc/default/rcS, however, when I drove down to the site and connected a monitor to this server today, I saw this:

screenshot of the initramfs prompt

I ran fsck.ext4 -fy /dev/sda1 and rebooted and now the server is back up and running.

I understand there are situations where just blindly running fsck -fy is dangerous and can lead to data loss. However, in my case, this is a physically inaccessible server and all the data is backed up in the cloud. It is paramount that Ubuntu does any and all steps possible to try to get it online.

Is there any way to force Ubuntu to always run fsck -fy, even if there are any "UNEXPECTED INCONSISTENCY" problems?

1 Answer 1

25
+50

Let me preface this with a disclaimer that if you have regular issues with unclean filesystems, even though you shutdown your system cleanly, you have grave underlying problems and its possible fsck can do more harm than good !

AFAIK there is no mechanism for an automatic fsck only if inconsistencies are found.

However, you do an fsck at every boot with some kernel parameters.

sudo nano /etc/default/grub

find the line that says

GRUB_CMDLINE_LINUX_DEFAULT

and add

fsck.mode=force  fsck.repair=yes

to the existing things there.

yes here should do the same as your FSCKFIX=yes in /etc/default/rcS or a manual fsck -fy. Personally I think preen would be safer, but then again it would hang on startup if the disk needs some more fixes that fsck does not deem "safe " and wants user interaction.

run

sudo update-grub

to update grup and verify it with

grep fsck /boot/grub/grub.cfg 

or have a look with an editor in /boot/grub/grub.cfg

If you then reboot, the filesystem should be checked, you can verify the last time it was checked (should be your boot time) with

sudo dumpe2fs -h /dev/your/device | grep checked
dumpe2fs 1.43.5 (04-Aug-2017)
Last checked:             Sun Feb 18 08:53:31 2018
4
  • Do you confirm that this method will prevent the system to switch to busybox on boot in case of "UNEXPECTED INCONSISTENCY"? thanks. Oct 13, 2020 at 7:29
  • @Poltergeist yes, it will try to fix it. If it can be fixed by fsck then it will continue to boot. Oct 13, 2020 at 8:14
  • Thanks for your help Robert. From my understanding, the system shows this busybox terminal on boot to let the user to do the fs check and approve the repair. According to tune2fs documentation, the default option for "fsck.mode" is "auto" (ensures that file system checks are done only when required) and the "fsck.repair" default value is "preen" (will only repair problems that can be safely fixed). So, don't you think the fsck.repair set to "yes" would be enough to avoid blocking the system boot in case problem are detected on the FS. What is your opinion? Oct 13, 2020 at 12:27
  • @Poltergeist no, not in this case. It depends. If you only have slight inconsistencies on your disk, then preen is enough. But as you can see in the screenshot, it detects problems than are not considered safe to automagically repair and specifically states that running it in auto or preen mode would result in the same warning and abort. The yes part overwrites this and tries to fix it anyway. So you will not be stuck on busybox on boot - if the inconsistencies can be repaired by one (manual or forced) fsck run. Dec 4, 2020 at 9:23

You must log in to answer this question.

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