Sunday, December 9, 2007

Creating An Independent Grub Without Losing Original Linux

Inspired by this essay,I decided to rearrange the partition on my laptop so that I would be able to install new OSs and chainload them easily.But the MBR is already occupied by Ubuntu,which means that there's not a boot loader in its own partition's boot sector. It is not chainloadable! With help from justlinux.com I finally figured out the way to make the partition chainloadable and chainloaded it by a independent GRUB newly installed on its own partition. My whole Ubuntu is installed on sda3, and I assigned 300MB as sda1 for the independent GRUB.Here comes what I did: On Ubuntu 7.10:
$ sudo mount -t ext3 /dev/sda1 /media/sda1 $ sudo mkdir /media/sda1/boot $ sudo mkdir /media/sda1/boot/sda1 $ cp /boot/grub/* /media/sda1/boot/grub
make /media/boot/grub/menu.lst like this:
defaulte 0 title Ubuntu Linux root (hd0,2) chainloader +1
Reboot the system,press "c" when GRUB appears.
Grub> root (hd0,0) Grub> setup (hd0) Grub> reboot
Again,You will find that the menu becomes the new one when GRUB appears,press "c"
Grub> root (hd0,2) Grub> setup(hd0) Grub> chanloader +1 Grub> boot
This time the GRUB menu on sda3 will appear.Which means that Ubuntu is chainloaded by the independent GRUB on sda1.And we needn't do any thing next time. Next time A new Linux being installed,just make sure it won't take over MBR, and add this to menu.lst on sda1:
title Name of new OS root (hdi,j) chainloader +1
(hdi,j) stands for the partition of the new system.

No comments: