HomePage » Linux » LinuxBoot » LinuxGrub2


Grub2

With grub2, one can have /boot on raid and lvm. Here are the steps to convert from regular /boot partition to raid+lvm boot partition. This is assuming one already has a working grub2 installation and it boots fine on the regular /boot partition. ubuntu made this extremely easy. Simply do a aptitude install grub2 and the wizard will take it from there. Use the chainloader option first so if something goes wrong, you can still boot with the existing grub1 loader. When satisfied, run the command stated in the boot screen to remove grub1 all together.

VGA modes
Some of the useful VGA modes (console resolution)
794: 1280x1024x16b
791: 1024x768x16b
788: 800x600x16b

Create the boot raid/lvm partition
First, create the raid/lvm /boot partition. In this case, I have /dev/sda2 as the regular /boot partition, and I have /dev/sdb2 of the same geometry.
mdadm --create /dev/md4 --level=1 --raid-devices=2 /dev/sdb2 missing
pvcreate /dev/md4
vgcreate -s512k vgmd4 /dev/md4
lvcreate -l203 -nboot vgmd4
mkfs.ext4 /dev/vgmd4/boot
mount /dev/vgmd4/boot /mirror-boot
rsync -av /boot/* /mirror-boot/


Few files that need update
At this point, you have a boot partition that's on raid+lvm. Edit /etc/fstab and /etc/mdadm/mdadm.conf with the necessary entries:
fstab
/dev/mapper/vgmd4-boot  /boot   ext4        defaults 0 0


For mdadm.conf, get a list of uuid using the following command. The newly created md4 is most likely not in this file. So, run the following command, then put these into the file
mdadm --examine --scan


Then of course /etc/grub/grub.cfg. Update the root uuid to the new one. In my case, the uuid is the one from /dev/vgmd4/boot. uuid can be obtained using the blkid command
/etc/grub/grub.cfg
search --fs-uuid --set 7161739a-d27a-4f5d-a05d-3b212f7da319


Next is to instruct grub2 to create a core.img that contains the necessary modules, and install it to the boot device
grub-install --modules="ext2 _chain pc gpt biosdisk lvm raid fs_uuid" /dev/sda


Generate core.img and run grub-install
Almost there. Now umount /boot and mount it on the raid/lvm partition. Then run grub-install with lvm and raid modules to generate core.img and install it to the boot device.

umount /boot
mount /dev/vgmd4/boot /boot
grub-install --modules="ext2 _chain pc gpt biosdisk lvm raid fs_uuid" /dev/sda
sync


Reboot
That's it. Reboot and good luck.


References
http://ramblingfoo.blogspot.com/2009/06/howto-transitioning-to-grub2.html

There are 2 comments on this page. [Display comments]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki