1

When booting I get into the grub menu, choose recovery mode, select fsck, yes However error saying root partition is already mounted. I thought this method was designed to allow this before the root partition is mounted.

Peter
  • 55

2 Answers2

3

In older versions of Ubuntu, fsck used to work from the Recovery Mode. However, later versions of Ubuntu leave the primary HDD/SSD mounted, so fsck no longer works.

Let's check/repair your filesystem...

  • boot to a Ubuntu Live DVD/USB in “Try Ubuntu” mode
  • open a terminal window by pressing Ctrl+Alt+T
  • type sudo fdisk -l
  • identify the /dev/sdXX device name for your "Linux Filesystem"
  • type sudo fsck -f /dev/sdXX, replacing sdXX with the number you found earlier
  • repeat the fsck command if there were errors
  • type reboot

Note: for Ubuntu Live, use Ubuntu Desktop, not Ubuntu Server (even if your environment is Ubuntu Server).

heynnema
  • 70,711
  • The fsck -f proposed in your solution unfortunately didn't work for me. fsck bails with a note that the /dev/sdaX is mounted. tune2fs marks mounts max count to 1 - so it does a fsck every time the OS boots... This can be reverted back to 29 (the default?). As you said, not ideal for sure, but it did work. Any ideas on how to force a fsck of a root filesys on reboot? It used to be possible now I can't find the flag for it. Doing a touch /forcefsck does seem to do something - after the reboot the file is gone, but I didn't see fsck was run during boot. Another "ugly" solution. :) – omahena May 16 '22 at 11:54
  • 1
    @omahena You tried to run fsck whilst booted to the Ubuntu disk... that's why it said it was mounted. You didn't do the very FIRST step... boot to a Ubuntu Live USB. – heynnema May 16 '22 at 13:07
  • Ah, you are right. I completely missed that. Apologies. I was trying to find a solution that doesn't require external bootable media. I am pretty sure the "force check" flag on fsck used to work differently in the past and marked the filesystem as dirty and asked you to reboot the system if the filesystem was in use. – omahena May 20 '22 at 07:56
2

Since posting the question I found 2 solutions on the net.

1.Force a fsck on each boot for an EXT4, EXT3 or EXT2 filesystem using: sudo tune2fs -c 1 /dev/sdXY eg sda3

2.This command uses Nano command line text editor to open /etc/default/grub so you can edit it: sudo nano /etc/default/grub

To force a fsck each time the computer boots, you'll need to add fsck.mode=force to GRUB_CMDLINE_LINUX_DEFAULT, at the end of the line but before the last quote (").

Example: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash fsck.mode=force"

After you've finished editing /etc/default/grub, update your Grub2 configuration: sudo update-grub

Peter
  • 55