Integrating Ubuntu boot config into CentOS 5.4 grub

It happened that I had installed my Ubuntu before my CentOS 5.4 OS..
and in the between got Windows XP installed..

Luckily all ubuntu partition have been set as ext3 (with Journal).
so can be mounted inside CentOS 5.4.

The step to recreate entry into CentOS grub for booting into ubuntu is as below :

1. mount the rootfs of Ubuntu into somewhere readable such as

mkdir -p /media/ubuntu
mount /dev/sda1 /media/ubuntu -t ext3

2. capture previous ubuntu boot config from its partition

cd /media/ubuntu/boot/grub/
vi grub.cfg

shall have something like this

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
 
### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
  have_grubenv=true
  load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
  saved_entry=${prev_saved_entry}
  save_env saved_entry
  prev_saved_entry=
  save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,2)
search --no-floppy --fs-uuid --set 1a2b230e-d172-4b48-8395-72a33ebce462
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
if [ ${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=10
fi
### END /etc/grub.d/00_header ###
 
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/white
### END /etc/grub.d/05_debian_theme ###
 
### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
        set quiet=1
        insmod ext2
        set root=(hd0,2)
        search --no-floppy --fs-uuid --set 1a2b230e-d172-4b48-8395-72a33ebce462
        linux   /boot/vmlinuz-2.6.31-14-generic root=UUID=1a2b230e-d172-4b48-8395-72a33ebce462 ro   quiet splash
        initrd  /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
        insmod ext2
        set root=(hd0,2)
        search --no-floppy --fs-uuid --set 1a2b230e-d172-4b48-8395-72a33ebce462
        linux   /boot/vmlinuz-2.6.31-14-generic root=UUID=1a2b230e-d172-4b48-8395-72a33ebce462 ro single 
        initrd  /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###

copy those line with root=UUID info

        set root=(hd0,2)
        linux   /boot/vmlinuz-2.6.31-14-generic root=UUID=1a2b230e-d172-4b48-8395-72a33ebce462 ro   quiet splash
        initrd  /boot/initrd.img-2.6.31-14-generic

3. copy out the necessary file (ubuntu vmlinuz and initrd) into current CentOS boot partition.

cp /media/ubuntu/boot/vmlinuz-2.6.31-14-generic /boot/
cp /media/ubuntu/boot/initrd.img-2.6.31-14-generic /boot/

4. edit the CentOS grub.conf
to have something like this..

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,4)
#          kernel /boot/vmlinuz-version ro root=/dev/sda5
#          initrd /boot/initrd-version.img
 
default=0
timeout=5
splashimage=(hd0,4)/boot/grub/splashmac3.xpm.gz
hiddenmenu
title CentOS (2.6.18-164.6.1.el5)
  root (hd0,4)
  kernel /boot/vmlinuz-2.6.18-164.6.1.el5 ro root=LABEL=/ rhgb quiet 
vga=791
  initrd /boot/initrd-2.6.18-164.6.1.el5.img
 
title Windows
  rootnoverify (hd0,1)
  chainloader +1
 
title Ubuntu 9.10 - Karmic Kaola
  root (hd0,4)
  kernel /boot/vmlinuz-2.6.31-14-generic root=UUID=1a2b230e-d172-4b48-8395-72a33ebce462 ro quiet splash
  initrd /boot/initrd.img-2.6.31-14-generic

Note : the root(hd0,4) is where CentOS “/boot” located.

4. that’s it.. might want to recheck with these..

grub-install --recheck --no-floppy /dev/sda

then reboot..
shall be able to get into Ubuntu Karmic Kaola with the grub menu ..

how nice Ubuntu tight it “rootfs” to “UUID=” instead of just “LABEL=/”

so.. Ubuntu actually can intelligently differentiate “/” partition between each “linux OS” so that would not messing up with one another “/” belonging to others….

while CentOS is just referring to partition with “LABEL=/”..
which is could be messing up if got multiple “linux rootfs” inside..
the system.. (consider if adding another hardisk from another CentOS to recover data .. and reboot. woohoo. .I bet will confuse which one is which..)

p/s : anyway.. messing up with hardisk could be a thrill… if you want to explore.. hehehee..

Related Post

8 Responses

  1. Arsento says:

    I liked it. So much useful material. I read with great interest.

    Reply
  2. aLe aRdHo says:

    Nice Articel, thanks for sharing 😉

    Reply
  3. watches says:

    OK. Bless you on your mission. watches

    Reply
  4. Suresh says:

    Thanks & All the Best.

    Reply
  5. jimmy choo outlet online says:

    Your article is very nice

    Reply
  6. Davein says:

    SO FUN ARTIAL

    Reply
  7. burberry bags says:

    ack Obama. Younger voters and liberals, too, but to a lesser extent. All are important Democratic constituencies that helped him win the White House in 2008 and whose support he’ll need to keep it next year. An analysis of Associated Press-GfK polls, includin

    Reply
  8. moncler says:

    I added it to favorites and i’ll be your constant reader.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *