Debian Lenny and grub with /boot in LVM
At last, I can put my /boot partition in LVM.
- Get the Debian box up to Lenny.
- Note that I accidentally trashed my MBR and had to boot into rescue mode while working out these steps. You shouldn’t do this if you follow all of the instructions, but you ought to have media handy.
aptitude install grub-pc
(Note: this will remove the old grub package and offer to chain load grub2 from your existing grub. Do this. If you have problems you can still boot.)- Verify you can reboot.
- Remove the old grub MBR and put in the grub2 one
with
upgrade-from-grub-legacy
- Hide your /boot/grub/menu.lst so you aren’t tempted to edit it.
- Your basic configuration, like kernel command line parameters is now in /etc/defaults/grub, there is also /etc/grub.d/* which I hope to never touch.
- Move your /boot into the LVM. You could tar up your /boot partition, unmount it, and extract it onto the root partition. You could also make a new LVM managed /boot if you like it on its own partition. I was out of space in the volume groups, so I went with /. If you didn’t make a new /boot, remember to take /boot out of /etc/fstab.
dd
zeros onto your old boot partition to make sure you aren’t deluding yourself.- Edit /etc/defaults/grub to add
GRUB_PRELOAD_MODULES=lvm
- Go back and make certain you did the previous step. I made an unbootable system before I learned that little tidbit.
- Do an
update-grub
and agrub-install /dev/sda
or whatever your disk is. - Go back and make sure you did the
grub-install
… Justupdate-grub
is not enough to pick up the lvm module. - Reboot and rejoice.
I am left wondering what silliness lead to GRUB-2 being version 1.96, but I am happy.
At some point in the past I managed to screw up my file server's lenny install in such a way that I ended up with the non-lvm ext2 boot partition commented out of fstab and a separate /boot directory on the lvm root.
I forgot about this incident and went about continuing to run apt-get dist-upgrade periodically. Everything worked until I went to squeeze and rebooted, at which point I made some more poor choices ("Why am I not running the new kernel? I'll just apt-get remove the old one!") and ended up unable to mount ext2 partitions (while still able to boot from one).
After about eight hours of head scratching I found this page and by following your steps had no trouble upgrading to GRUB 2 which booted the new kernel which fixed all the problems, allowing me to get on with my life (such as it is).
You are awesome and so is GRUB 2.
Thanks for the info though, it helped me to confirm what I was doing would work before I sent a remote machine through a reboot (I know, dangeous, but couldn't be helped)
Debian 6.0.4 installer .iso
6 virtual disk devices
-> one physical raid partition per device
-> one RAID6 md0
One physical volume group
logical volume /
logical volume /home
The system does not manage to boot even after going in into the rescue mode and making sure grub is both configured and installed with the lvm module preloading (/etc/default/grub -> update-grub -> grub-install).
It all trips up in grub-pc (GRUB2) somehow and I do not know how to debug it.
Any pointers? Did I miss and mess up any of the rescue mode superhero stuff?
I've seen some indirect talk about mdraid + LVM + EXT4 not being a bootable combo yet, but then again I've seen people boast about their mdraid + dmcrypt + LVM + EXT4 / BTRFS setups.
I guess I will just fall back to a good old fashioned EXT2 boot partition.
Here's my rubber chicken waving approach for the internet:
update-grub
grub-install --modules="search_fs_uuid raid raid5rec raid6rec mdraid lvm ext2 chain pci" /dev/sda