Sometimes I take my hard drives and juggle them up into the air before I put them randomly back into my computer. Well, perhaps not, but putting in a new drive or doing a BIOS update can do pretty much the same thing to the ordering of your disks. This is why most “techy” people (you know those that juggle their disks up into the air) end up with some sort of volume management, and in my case LVM. This makes it possible to have volume names rather than drive + partition number decide what is what. Now this only solves half the problem, because you still have to boot of a random drive. This is where grub2 shines (for me atleast), latest version (of this writing) actually supports having the boot partition (containing your kernel and grub configuration files) on an LVM partition. In other words we can use this to juggle as much as we want without having to update our bootloader all the time:
So for the practical example of grub2 (of course you have to be able to install it yourself first, be it apt-get/emerge/configure&&make install/rpm..) .. For what I needed I made one pc style partition on all the drives (on my system this gives med /dev/sda1 and /dev/sdb1). I do the usual LVM voodoo and ends up with /dev/somevg/bootlv which I mount on /boot. Now to the fun part: In grub2 you build your boot loader from modules to create the perfect bootloader, we will use the modules pc (so that it understands pc-style partitions), ext2 (so that it can read ext2 file system) and lvm (so that it can understand lvm). Of course there are other modules that are useful, but these can be loaded dynamically from the boot partition when needed.
Installing is easy:
grub-install –modules=”pc ext2 lvm” /dev/sda
This should have figured out everything it ever needed to know, unfortunately this is not the case and it complains about not finding (somevg-bootlv). But what it does do for us is copying all the modules needed into /boot/grub and creating core.img with pc, ext2 and lvm modules in it. But for the actual installation of the bootsector and bootstrapping modules:
grub-setup -r (somevg-bootlv) (hd0)
you may need to escape those parenthesis \( \), depends on your shell .. If you want to be able to boot off any drive, just install it onto all of them (hd0 and hd1 in my case).
Anyways, the format of the configuration has changed, and so has the configuration filename, it is now called grub.cfg, here is an example:
set timeout=10 set default=0 menuentry "Gentoo Linux Default" { set root=(somevg-boot) linux /vmlinuz dolvm2 root=/dev/somevg/root ramdisk=16384 vga=1 initrd /initramfs-genkernel-x86_64-2.6.18-gentoo-r1 }
Hope this helps:)
Leave a Reply