20

I'm on Ubuntu 16, and I'm trying to repair my startup disk. I have followed the instructions here, but once I'm at the root access of Recovery mode, it still says that the disk is mounted and it can't run. If I try sudo fsck -f /dev/sda3, it just replies:

fsck from util-linux. Anyone know why it might do that? According to this question, when fsck reports this command, you have to use fsck.ext4. However, when I do that, I still get a message about the volume being in use.

I see there's another question about this on Ubuntu 18, but there's no answer.

Most answers suggest using a Live Disk, but Etcher isn't working on MacOS at the moment, and it's surely not unreasonable to get this done from the recovery command prompt.

It's a vanilla Ubuntu install on a Dell Inspiron laptop.

Performing umount /dev/sda3 gives me "/dev/sda3 not mounted."
Performing fsck.ext4 -f /dev/sda3 gives me "/dev/sda3 is in use".

The output of lsblk /dev/sda gives:

sda                     disk
   sda2                 part
   sda3                 part
      ubuntu--vg-root   lvm   /
   sda1                 part

(obviously, I'm typing this in on another computer) I've left out the sizes, hope that's clear.

I've also tried umount -lf /. After doing that, when I run fsck, I get a message that it cannot check if the filesystem is mounted due to missing mtab file.

Terrance
  • 41,612
  • 7
  • 124
  • 183
benwiggy
  • 253
  • 1
  • 2
  • 9
  • you want to repair the linux's partition ? – Iyadh Jedidi Mar 10 '19 at 11:20
  • Yes. of course! – benwiggy Mar 10 '19 at 12:04
  • The instructions you linked to have an entire section "If for some reason you can't do the above..." Follow those instructions. – user535733 Mar 10 '19 at 12:52
  • So there's no way of repairing the disk without making a Live image on some other disk or DVD? Wow. – benwiggy Mar 10 '19 at 12:59
  • Often such repairs are possible. In your (unusual) case, appears not. We don't know why your case is unusual, since we don't know the history. Wow. – user535733 Mar 10 '19 at 13:43
  • What would you need to know? It's clearly not that unusual, as there are people asking the question here and elsewhere. It's a bit surprising that there aren't general steps to ensure that you can fsck a disk. – benwiggy Mar 10 '19 at 14:02
  • Partition needs to be unmounted, that is why live installer is normally suggested. But if you can boot recovery mode then you can run fsck from that with partition(s) unmounted. – oldfred Mar 10 '19 at 15:53
  • @oldfred Any advice on how to unmount it? I've had no luck. – benwiggy Mar 10 '19 at 16:00
  • You might want to see https://www.linuxquestions.org/questions/fedora-35/problem-running-fsck-on-lvm-642750/ as you need the Volume name to check with fsck. It should be the same commands for checking LVM – Terrance Mar 10 '19 at 16:14
  • @Terrance Thanks, but I'm having trouble comprehending that page. I've tried fsck.ext4 -f /dev/ubuntu-vg-root (based on the output of pvscan) but it gives no such device. – benwiggy Mar 10 '19 at 16:20
  • 1
    I had to sit myself in front of a system to get a good answer for you. I ended up removing my previous comments as at this point they are not needed. It can be difficult to come up with an answer if I am not seeing what you are seeing. Glad I was able to come up with something that could help you! =) – Terrance Mar 13 '19 at 23:46

2 Answers2

42

To check the LVM it is done with the following steps.

First we can see our drive layout with lsblk:

# lsblk
NAME                 MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                    8:0    0    20G  0 disk  
└─sda1                 8:1    0    20G  0 part  
  └─xubuntu--vg-root 253:0    0    19G  0 lvm   / 
sr0                   11:0    1  1024M  0 rom   

as we can see the LVM is named xubuntu--vg-root, but we cannot run fsck on this name as it will not find it. We need to get the whole name. To do this we are going to run the lvm lvscan command to get the LV name so we can run fsck on the LVM.

The following commands should be ran as sudo or as a root user.

# lvscan
  inactive          '/dev/xubuntu-vg/root' [<19.04 GiB] inherit
  inactive          '/dev/xubuntu-vg/swap_1' [980.00 MiB] inherit

As we can see our name to check is /dev/xubuntu-vg/root so we should be able to run fsck on that name

If the /dev/xubuntu-vg/root is not ACTIVE, we need to make it active so that we can run the check on it

lvchange -ay /dev/xubuntu-vg/root

Now it should look like this:

# lvscan
  ACTIVE            '/dev/xubuntu-vg/root' [<19.04 GiB] inherit
  inactive          '/dev/xubuntu-vg/swap_1' [980.00 MiB] inherit

Now we can run the fsck on the LVM volume.

fsck /dev/xubuntu-vg/root

or to run a forced check with assume yes

fsck -fy /dev/xubuntu-vg/root

Adding a screen shot since VirtualBox will not let me copy and paste.

enter image description here

Hope this helps!

Terrance
  • 41,612
  • 7
  • 124
  • 183
-1

You can try this command:

sudo fsck.ext4 -f /dev/sda6

assuming Ubuntu is on /dev/sda6.

fosslinux
  • 3,831
  • Please see my question. I've tried that exact command (with sda3, which is where Ubuntu is), and I get a message that it is in use. – benwiggy Mar 11 '19 at 07:18
  • mount it before doing anything (use the mount command with the ds3 partition) and then you can use the command that i gave to u – Iyadh Jedidi Mar 12 '19 at 14:21
  • So, I should mount a volume that is already mounted, and then unmount it with a command that already doesn't work? – benwiggy Mar 12 '19 at 17:21
  • try sudo mount -o remount,ro / ... if this doesn't work, then something is running off the root partition and you are not in the proper recovery mode.. – Robert Riedl Mar 12 '19 at 18:19