Integrating Ubuntu boot config into CentOS 5.4 grub


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

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

2 Responses

  1. namran says:

    ok..i am leaving now..no update until2 decc

    Reply
  2. namran says:

    I am going to be away to Papua New Guinea ..

    until 2nd December 2009..

    so .. my dear reader..

    can expect no update until then.
    unless i can find internet access from there.

    take care..!

    Reply

Leave a Reply

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