Articles » Linux Troubleshooting » Fixing "Gave up waiting for root device" error in Debian

Fixing "Gave up waiting for root device" error in Debian

Yesterday I decided to do a full upgrade of my Debian server (apt-get dist-upgrade), and ended up regretting it. After it was finished, the machine would no longer boot. It would stop with the following message:

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/<<removed>> does not exist.
Dropping to a shell!

NOTE: <<removed>> was actually the name given to the root partition, which is not important.

I spent a very long evening scouring the internet for possible solutions, and found that none of them worked. The problem was caused by the upgrade switching to using initramfs for booting. Initramfs is a RAM filesystem that is supposed to contain everything needed to boot the system. Well, my Debian installation used logical volumes instead of plain partitions, and the necessary modules weren't included in initramfs.

Eventually I stumbled upon this page on a blog by Uwe Hermann, which described both the cause, and the solution. Basically, the lvm2 and cryptsetup packages were missing (or had been deleted).** To fix the problem, the following was done:

  • Booted from a Debian Live Rescue CD image;
  • Selected rescue mode from the rescue CD's boot menu;
  • Started a shell with the root set to /dev/mapper<<removed>> (it's in the menu, so there's nothing special to do);
  • Mounted the boot partition (/dev/sda1 in my case): "mount /dev/sda1 /boot"; and
  • Executed: "apt-get install lvm2 cryptsetup".

That's it. The installation of those two modules automatically triggers an initramfs rebuild. This rebuild requires that the boot partition be correctly mounted. If you forget to mount it first, then you can always mount it later, and execute "update-initramfs -u" manually.

 

FINAL NOTES:

  • I'm not sure if cryptsetup was actually needed, but it was too late for me to bother experimenting; and
  • There are a number of other reasons why you could get the same error message. So, the solution on this page is not guaranteed to work for everyone.




Articles » Linux Troubleshooting » Fixing "Gave up waiting for root device" error in Debian