Posted by: richlyn | July 16, 2009

Making a dedicated Grub partition

I started my journey with Linux (ubuntu to be precise) with the 7.10 Gutsy Gibbon and from there on have been slowly learning things by trial and error (one learns more when one gets into troubles!) After Gutsy i also installed Intrepid (I am not crazy of everything just coz its new , but there were reasons in the technicalities why the new versions were better) Meanwhile i got to collecting movies and eventually needed more space. So i got another 500 GB HDD and installed 9.04 Jaunty Jackalope on it. I ended up with Two HDD – one having WIN XP, Gutsy and Intrepid and the other having Jaunty. I decided to do away with Gutsy and reinstall WIN XP with an updated XP3 version. Thats when the problems came up!

The MBR was messed up and i could not boot to any of the Linux distros. I changed the master and slave config of the HDD and reinstalled Jaunty on the secondary HDD again remapping the data partition for the movies but it still booted to Windows without detecting Linux at all. I booted with the Live CD and tried to redo the MBR with the grub command but it gave me an error so i decided i had had enough of this MBR and a fix is necessary once and for all. hence the necessith of making a dedicated Grub partition, so that no matter what i did to all my distros i still had my Grub intact!!

Heres how i did it (ofcourse i had to haggle a lot, but its easy once you know it)

Boot in with a live CD
1) make a small partition (newer distros have a partition manager,so its simply easy)
a 7 MB is just enough.

2) Label your file system.
Code:
$ sudo fdisk -lu
Code:
$ e2label /dev/sda10 GRUB
Code:
$ ls /media
Reboot your computer, and mount the new GRUB partition. for example (hd0,10)

3) Make a directory “boot” in your new GRUB partition (in /media/GRUB)
Code:
$ sudo mkdir /media/GRUB/boot

4) Copy your /boot/grub directory(that is inside this working linux already) to the new GRUB partition,
Code:
$ sudo cp -r /boot/grub /media/GRUB/boot/
(again in newer distros you can manually copy paste using CTRL+C and CRTL+V)

5) Edit the new GRUB partition’s menu.lst file by …
Code:
$ sudo gedit /media/GRUB/boot/grub/menu.lst

6) Delete all the old operating system boot entries, and the entire Debian Automagic Kernels List too.
Example of Multi Boot menu.lst (GRUB partition’s menu.lst)

title Ubuntu 8.04 (/dev/sda6)
root (hd0,5)
chainloader +1

title ArtistX 0.6 Ubuntu 8.10 (/dev/sda7)
root (hd0,6)
chainloader +1

title Microsoft Windows XP Professional
root (hd0,0)
savedefault
chainloader +1

Note: Don’t get confused! The above menu.lst [the main GRUB menu.lst] is the first menu you will see, so you can choose which distro you want to boot, then you will see each linux distro’s menu.lst, which is just the normal menu.lst listing different kernel versions under that distro.

7) Re-install Grub from your new GRUB partition to MBR.
(Notice the order FROM abc TO xyz)
Code:
$ sudo grub
Code:
grub> find /boot/grub/stage1
(hd0,1)
(hd0,7)
(hd0,9)
(hd1,1)
Code:
grub> root (hd0,9)
Code:
grub> setup (hd0)
Code:
grub> quit
Note, sometimes GRUB gets the device label wrong…
for example, when using “sudo grub” inside a workig linux os, “find” command returns (hd0,9)
but at grub command line before booting into that linux os, “find” command returns (hd1,5)
so just manually edit the main GRUB menu.lst

Finally give all your operating systems a test boot-up to make sure everything’s working fine.

EXTRA STEPS
later, when installing a new linux distro into a partition, for example, partition LinuxY,
just make sure to install bootloader Grub or Lilo into that partition LinuxY
in Ubuntu, at the last HD installation step, there is a small button “Advanced Options”, click on it, then choose to install bootloader Grub into LinuxY
(Not to install it into MBR, which is hd0 or hd1 )

(by the way, in the earlier steps, you only need to select one / partition[root partition], and one swap partition [… so edit all other swap partitions for “NOT TO BE USED”] )
After linux HD installation, add lines like below into the main GRUB menu.lst that is inside the dedicated Grub partition

title Ubuntu 9.04 (/dev/sda9)
root (hd0,8)
chainloader +1

if that linux has to install its /boot as a separate partition, (hd0,9), then just edit the main GRUB menu.lst according to where that /boot partition is

title Fedora 11 (/dev/sda10)
root (hd0,9)
chainloader +1

Fun thing to do… add lines below into each linux distro’s menu.lst, that will get you back to the main menu!
title Main Menu (/dev/sda8)
root (hd0)
chainloader +1


Responses

  1. How to do this whith GRUB 2?
    GRUB 2 does not have menu.lst

  2. With the new ubuntu 9.10 the grub version has changed and its a completely new config. So we’ll need to wait and watch till some tried and tested method comes up.
    meanwhile you can look up
    http://ubuntuforums.org/showthread.php?t=1320270
    http://members.iinet.net/~herman546/p20/GRUB2%20Bash%20Commands.html#grub-install

  3. […] I installed another OS and didn't copy bookmarks. I did find this site so you could check it out: https://rxezlqu.wordpress.com/2009/07…rub-partition/ It uses Legacy Grub so you will need to have a Linux distro which uses it, basically anything […]

  4. […] Making a dedicated Grub partition July 2009 3 comments 5 […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: