9

When I boot up I get a screen saying:

Gave up waiting for root device

Then it lists common problems:

ALERT! /dev/mapper/ubuntu--vg-root does npt exist. Dropping to a shell!

Then I get an initramfs prompt.

Is this fixable without a backup?

I can't remember exactly what I did to make this stop working...

(My hard disk is NOT encrypted.)

12

Ubuntu's LVM autodetect didn't work at all for me either. To fix it, I made a script in

/etc/initramfs-tools/scripts/local-top/forcelvm

with the following contents:

#!/bin/sh
PREREQ=""
prereqs()
{
   echo "$PREREQ"
}
case $1 in
prereqs)
   prereqs
   exit 0
   ;;
esac
. /scripts/functions
# Begin real processing below this line

# This was necessary because ubuntu's LVM autodetect is completely broken. This
# is the only line they needed in their script. It makes no sense.
# How was this so hard for you to do, Ubuntu?!?!?
lvm vgchange -ay

Then did

# chmod +x `/etc/initramfs-tools/scripts/local-top/forcelvm`

for good measure and

# update-initramfs -u -k all

That fixed everything, while persisting after a system update.

| improve this answer | |
  • This is the real working solution to this annoying problem. I encountered this issue when upgrading my long running VirtualBox VM (initially built back in 2008 @ 8.04) from 16.04 to 18.04. It failed to boot into the latest kernel (4.15.0-23) while it can still boot into the 16.04 kernel (4.4.0-xx whose initramfs / initrd image was not updated during the process). Looking at the error message in console it indicated that the LVM VGs/LVs were not activated (root found found) and thus dropped into initramfs. I am yet to understand why such a bug can still hit us in 18.04. – Terry Wang Jun 19 '18 at 23:46
  • Worked well and restored my boot after upgrading to 16.04 – Oleg Gryb Dec 15 '18 at 1:58
  • On Linux-parisc(debian 10.3 buster) the lvm bug is still present, on amd or Intel no problem, on parisc the root lvm is missing and system boot in initramfs mode, your script works filne, thanks. – elbarna Mar 4 at 17:19
4

Try a temporary workaround

In initramfs prompt type:

vgchange -ay

Sample output:

logical volume(s) in volume group "vg1000" now active

Followed by:

exit

If you have a LVM snapshot of root partition, that's a bug #360237. I solve this issue removing/deleting that snapshot.

If not your case, try fix doing this.

Another related bugs: #1396213, #29858, #1163406

| improve this answer | |
  • 1
    This saved me after 2 days logged out of my machine in initramfs with a similar error. Can someone explain what vgchange -ay actually does? and why it worked? thank you. – Massagran Sep 8 '15 at 19:55
  • 1
    vgchange -ay in the (initramfs) prompt returns /bin/sh: vgchange: not found for me :( – knocte Oct 2 '16 at 10:17
3

1

In initramfs, type:

     #/sbin/lvm vgchange -a y
     #vgchange -a y
     #exit

If you're unable to solve the issue, type this:

ls /dev/mapper Now, you should have found root (like /dev/vgname/lvname).

reboot And then select a kernel on the screen and select e to edit and paste a root value (like /dev/vgname/lvname) at:

/boot/vmlinuxxxxx root=uuid/dev/xxx. Then, finally, press Ctrl+X to boot.

If problem repeats when reboot the server

go to

#/boot/grub/grub.cfg at /vm/vmlinuz root=write your full lv path

if problem not fixed try fix initramfs as below

1.Go to server terminal

  # sudo rmmod floppy

   #echo "blacklist floppy" | sudo tee /etc/modprobe.d/blacklis-floppy.conf

#dpkg-reconfigure initramfs-tools #update-initramfs -u #update-grub #reboot Execute this

#/etc/initramfs-tools/scripts/local-top/forcelvm with the following contents:

#!/bin/sh PREREQ="" prereqs() { echo "$PREREQ" } case $1 in prereqs) prereqs exit 0 ;; esac . /scripts/functions lvm vgchange -ay Then do

   # chmod +x `/etc/initramfs-tools/scripts/local-top/forcelvm`
   # update-initramfs -u -k all

take backup of lvm2

    #apt-get install lvm2
    #cp /usr/share/initramfs-tools/scripts/local-top/lvm2  /tmp

Edit lvm2

      #vi /usr/share/initramfs-tools/scripts/local-top/lvm2

write Between modprobe -q dm-mod and activate_vg "$ROOT" add this line to initialize your lvm:

lvm vgchange -ayactivate_vg "$ROOT" if you not find this line

write below two line at the end of the file above exit 0

       #lvm vgchange -ayactivate_vg "$ROOT"
       #activate_vg="$ROOT"

save the file then

        #update-initramfs -u
        #update-grub
        #reboot
| improve this answer | |
1

For some of you it might be a problem in your grub.cfg:

Stumbled about the same problem (root not found as lvm volume groups were not activated by initrd) today on 18.04. I figured out that the volume groups are automatically activated if you specify your root device in the "grub.cfg" via device name

linux   /vmlinuz root=/dev/mapper/vg-root

where as they are not automatically activated if you specify it per UUID

linux   /vmlinuz root=UUID=abcd-[...]

Thus there had to be some script in initrd which contains this logic.

| improve this answer | |
0
  1. Backup

    /usr/share/initramfs-tools/scripts/local-top/lvm2
    
  2. Edit

    /usr/share/initramfs-tools/scripts/local-top/lvm2
    
  3. Between modprobe -q dm-mod and activate_vg "$ROOT" add this line to initialize your lvm:

    lvm vgchange -ayactivate_vg "$ROOT"
    
  4. Rebuild your initramfs:

    sudo update-initramfs -u
    
  5. Rebuild your grub cfg:

     sudo update-grub
    

Enjoy! :-)

| improve this answer | |
  • what if /usr/share/initramfs-tools doesn't exist for me? – knocte Oct 2 '16 at 10:18
  • That's a terrible idea. Make your changes in /etc/initramfs-tools/scripts for them to persist between system updates. – enigmaticPhysicist Oct 8 '16 at 16:03
  • Not recommended approach to make changes to files provided by a package. The change may get overridden by package updates or the change can be unintentionally kept (hidden), causing more issues than it solves. – Terry Wang Jun 20 '18 at 3:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.