Can't find LVM root dropped back to initramfs
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.)
Solution 1:
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.
Solution 2:
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
Solution 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
Solution 4:
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.