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

3 Responses

  1. robfish88 says:

    Thank you very much…….

    Reply
  2. robfish88 says:

    Kindly advice, I want to use OpenWRT for my TP-Link router model TL-WR1043ND version 1.10 starting serial number with 12.

    Requested for UNIFI Malaysia 20 MB

    Kindly advice which files I do need to download, highly appropriated in advance .

    Regards

    Robert

    (Shah Alam)

    Reply
  3. robfish88 says:

    Good Morning ,
    I have a TL-WR1043ND router Ver 1.10 and not able to find Hardware version, as what I understood from other posts that this should be then Hardware version 1.
    Have installed OpenWRT in total 3 files :
    German stock firmware (v3.9.17)
    – attitude_adjustment 12.09-rc2 and
    attitude_adjustment 12.09-rc2 and able to able access my router TL-WRT1043ND

    I guess that it is my age (59) but I a losing it on the configuration and explanation, first the first of all on many images that I have seen on the internet in the part Internet -> Swith VLAN witch is starting with PORT 1 -2-3-4-5-CPU however on my installed OpenWRT it starts with PORT 0-1-2-3-4-CPU so I guess something is already wrong on my side, having said this most images are related to HARDWARE VERSION 1.8

    My main goal is to get connect to UNIFI Malaysia (20MB connection) I know that Unifi provides an IPTV package but to honest I don’t need this IPTV connection at all.

    The bottom line, I like get connected to UNIFI with OPENWRT and I am really begging f someone can assist me in to get connect to Unifi. I know it is labor day (May 1) but will be great full if somebody can assist me.

    Reply

Leave a Reply

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