37

today I installed Ubuntu 64-bit on a netbook. When the netbook boots this, error report appeared. I think there is a problem with the partitions.

Gave up waiting for root device. Common problems:
  — Boot args (cat /proc/cmdline)
    — Check rootdelay= (did the system wait long enough?)
    — Check root= (did the system wait for the right device?)
  — Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/mapper/ubuntu--vg-root does not exist. Dropping to a shell! 

BusyBox v.1.21.1 (Ubuntu 1:1.21.1-1ubuntu1) built-in shell (ash)   
Enter 'help' for list of built-in commands.  

(initramfs)

Output of lsblk as requested:

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 232.9G  0 disk 
├─sda1   8:1    0   231G  0 part 
├─sda2   8:2    0     1K  0 part 
└─sda5   8:5    0     2G  0 part [SWAP]
sr0     11:0    1   1.2G  0 rom  /cdrom
loop0    7:0    0   1.1G  1 loop /rofs
knocte
  • 996

9 Answers9

38

In certain Ubuntu versions (e.g. Xubuntu 18.10) this issue might be caused by an apt autoremove. Due to this bug apt will suggest to remove

cryptsetup cryptsetup-bin cryptsetup-initramfs cryptsetup-run dmeventd libdevmapper-event1.02.1 liblvm2app2.2 liblvm2cmd2.02 libreadline5 lvm2

which makes the system non-bootable (because the root partiation cannot be mounted and unencrypted using LVM).

If you are not using LVM and disk encryption this answer is probably not for you.

I was able to fix it by re-installing cryptsetup and lvm2 in a chroot environment: boot from a live USB stick, run commands below in a terminal, reboot.

# find root partition
sudo fdisk -l

unencrypt partition

Note: replace /dev/nvme0n1p3 with your disk

replace "nvme0n1p3_crypt" with the correct name

check by running this in chroot:

$ cat /etc/crypttab | cut -f1 -d " "

nvme0n1p3_crypt

sudo cryptsetup luksOpen /dev/nvme0n1p3 nvme0n1p3_crypt

mount root partition

sudo vgscan sudo vgchange -ay sudo mount /dev/mapper/xubuntu--vg-root /mnt

prepare chroot environment

sudo mount /dev/nvme0n1p2 /mnt/boot/ # replace nvme0n1p2 with your boot partition! sudo mount -o rbind /dev/ /mnt/dev/ sudo mount -t proc proc /mnt/proc/ sudo mount -t sysfs sys /mnt/sys/

make dns available in chroot

sudo cp /etc/resolv.conf /mnt/etc/resolv.conf

enter chroot

sudo chroot /mnt /bin/bash

re-install missing packages

apt install cryptsetup lvm2

re-generate (this might be done also by apt in the step before, I'm not sure)

update-initramfs -u -k all

Leave chroot environment - not sure if the following is really necessary...

exit

Write buffers to disk

sudo sync

Unmount file systems

sudo umount /mnt/sys sudo umount /mnt/proc sudo umount /mnt/boot

This Q&A helped me collecting the commands.

This Q&A is kind of related, but maybe not relevant for you anylonger if you are having this issue already.

lumbric
  • 3,994
  • 4
    Ohh, you just saved me about three days of work I'd put into setting up a new device. Worked perfectly! Replaced nvme0n1p3 with sda5 and nvme0n1p2 with sda1 (linux partition inside the LVM and the small boot partition outside the LVM, respectively) – Oliver U Feb 26 '19 at 16:51
  • 1
    @OliverU great that it worked! Even if you can't make it boot anymore, you should be still able to copy your home directory and maybe parts of /etc or so to a fresh install. That should be probably less work than the inital setup. – lumbric Feb 27 '19 at 12:10
  • 3
    Worked perfectly for Ubuntu 18.10, where the problem happened to me after apt autoremove issue. Like Oliver above, I just had to replace the following in the instructions: nvme0n1p3sda5, nvme0n1p3sda5_crypt, nvme0n1p2sda1. Wit the right guess like that, no need to enter chroot twice as cat /etc/crypttab | cut -f1 -d " " inside chroot will just confirm you made the right guess. If you need to enter twice, do so after a reboot as closing and reopening the crytpsetup + LVM2 environment without rebooting seems … complex. – tanius Sep 29 '19 at 20:58
  • Also to note, these instructions worked great with the non-booting hard drive put into a drive enclosure and attached to another (properly working) Ubuntu computer via USB. No need for a live system then. – tanius Sep 29 '19 at 20:59
  • Thanks man, this helped after 4 hours of trying to fix this. Works even on Ubuntu 19.10 – WellBloud Oct 25 '19 at 10:40
  • This greatly helped me as well after I accidentally deleted some apparently important packages (even though cryptsetup and lvm2 were not directly removed). I accidentally did this: sudo apt remove busybox-static fakeroot git dmsetup kpartx netcat-openbsd nmap python-psycopg2 python3-psycopg2 snmp uml-utilities util-linux vlan. And then an apt autoremove which seems to have done the damage. – grssnbchr Nov 15 '20 at 21:00
  • I think I had the same problem some time ago, but in my case I was still able to boot with an older kernel and then reinstall the autoremoved packages directly. If that is an option it might be considerably easier than the above. – tobias_k Feb 01 '21 at 10:04
  • 3
    In my case, the missing bit was apt install cryptsetup-initramfs from chroot environment. – Adobe Jul 12 '21 at 10:55
  • 1
    In my case, nothing seemed to get installed when I ran apt inside the chroot shell. I think what did the trick was modifying /etc/crypttab (inside the chroot shell) to say nvme0n1p3_crypt UUID=[…] none luks,discard instead of crypt_dev_nvme0n1p3 UUID=[…] /etc/luks-keys/crypt_dev_nvme0n1p3 luks,discard. But I don't know for sure. – Simon Alling Jan 17 '22 at 17:48
  • 1
    This helped me a lot. Thanks! – Anar Amrastanov Jan 25 '22 at 23:34
  • 1
    Saved me from having to reinstall, thanks – P Varga Dec 21 '22 at 00:11
  • It was very helpful. At first, I thought my system was lost. Now it is repaired, worked for 20.04 version. Thank you! – Lysenko Andrii Feb 22 '23 at 17:27
  • Incredible answer. xubuntu--vg-root was ubuntu--vg-root for me. Also worth noting that cat /etc/crypttab | cut -f1 -d " " should be run from within chroot – forgetso Aug 02 '23 at 11:09
  • A few questions / comments for @lumbric if he is still updating this answer: – rik-shaw Dec 14 '23 at 19:46
  • I think you have to unencrypt to then read /etc/crypttab to find the correct volume name. If it needs changed, then have to either restart or close the volume, re-encrypt, and start again, unencrypting with correct volume name? Not sure if there is an easier way? Anyway, may need clarifying?
  • – rik-shaw Dec 14 '23 at 19:56
  • The syntax of the mount commands with -t were giving me some problems. Instead is it OK to adjust syntax to sudo mount --bind /proc /mnt/proc (and same for /sys)?
  • – rik-shaw Dec 14 '23 at 19:56
  • To not blow away a users /etc/resolv.conf since it is a symlink to ../run/systemd/resolve/stub-resolv.conf for newer Ubuntu installs it would be good to also bind /run: sudo mount --bind /run /mnt/run
  • – rik-shaw Dec 14 '23 at 19:57