Ubuntu won’t boot raided root

Well, I’ve had a lot of trouble switching my system from LVM, to RAID1+LVM on ubuntu 10.04.  I got another drive for my system, created a mirror with one drive (temporarily of course) asked lvm to move my entire system over to that physical device, added the previous drive to the raid array, and rebooted (oops).  I am listing a few things that are important to know when you’re both new to Ubuntu, and doing raid post installation of Ubuntu.

First and foremost, it is very important that you realize the need to run both update-initramfs and update-grub.  update-grub re-configures grub based on your current system configuration.  Things like where /boot resides,  and things of that nature, will be automagically updated in the grub configuration by running update-grub.  update-initramfs takes care of any booting issues you might have post grub, such as raid.  So, any time you make a system change that might affect booting, run these commands before rebooting (thanks to Jordan_U on irc.freenode.org for tips)…

update-grub
update-initramfs -ck all # all kernels and create (not update) the initramfs.

In the event of changing your /boot fs to another location, you should run the following as well.  Thanks again to Jordan_U.

dpkg-reconfigure grub-pc

This ensure that

  1. You can configure the devices that grub will install to
  2. Ubuntu is aware of proper system configurations, for when upgrades occurs and what not, so that it doesn’t write the improper grub.cfg
  3. update-grub is run automatically
  4. installs grub to the devices configured

Now, the particular problem I was having, even though I was running the above commands, is that I kept getting dropped to a shell, with an error that said “ALERT! /dev/mapper/sys-ubuntu does not exist. Dropping to a shell“.   So, as we can see, it was not finding my lvm root system.  So, the big question is “Why?”  Well, after poking around the system a bit, to find out what update-initramfs was doing, I found a file in /usr/share/initramfs-tools/hooks/mdadm that was copying /etc/mdadm/mdadm.conf verbatim to the initramfs.  Well, it’s supposed to “auto detect” my raid arrays, with that configuration, but it doesn’t.  So, the way I fixed it was to run the following commands…

mdadm --detail --scan > /etc/mdadm/mdadm.conf
update-initramfs -ck all

I then rebooted, and my system was very happy, and booted up very quickly. I have since filed a bug report on ubuntu’s launchpad.