View Full Version : [SOLVED] GRUB issue while multi-booting CentOS 5.5, Ubuntu, Wind

November 20th, 2010, 11:41 AM
I have a laptop with one hard disk partitioned 3 ways with vista on the first partition, CentOS 5.5 on the second and Ubuntu 10.04 on the third. I installed CentOS last over a Fedora installation. Before that the GRUB 2 on the Ubuntu partition was doing the bootloading and everything was fine. Now GRUB 1 on the CentOS partition has the job and I can't load Ubuntu. The problem seems to be that GRUB can't read anything on the Ubuntu partition. Here's some info:

Here's fdisk:

[root@seven ~]# fdisk -l

Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 12752 102424576 7 HPFS/NTFS
/dev/sda2 12752 25503 102424576 83 Linux
/dev/sda3 25503 37782 98633728 83 Linux
/dev/sda4 37783 38913 9084727 5 Extended
/dev/sda5 37783 38913 9084726 82 Linux swap / Solaris

Here's what grub gives me. Notice that it doesn't like any file on the 3rd partition.

GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]

grub> root
(fd0): Filesystem type unknown, partition type 0x0

grub> find /boot/grub/stage1

grub> root (hd0,2)
Filesystem type is ext2fs, partition type 0x83

grub> cat /root.txt

Error 2: Bad file or directory type

I can however mount the 3rd partition and read /root.txt

[root@seven ~]# ls /mnt/ubuntu/
bin etc lib opt sbin tmp vmlinuz.old
boot home lost+found proc selinux usr
cdrom initrd.img media root srv var
dev initrd.img.old mnt root.txt sys vmlinuz
[root@seven ~]# cat /mnt/ubuntu/root.txt
this is /

Here's /boot/grub/grub.conf:

[root@seven ~]# cat /boot/grub/grub.conf
# 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,1)
# kernel /boot/vmlinuz-version ro root=/dev/sda2
# initrd /boot/initrd-version.img
title CentOS (2.6.18-194.el5)
root (hd0,1)
kernel /boot/vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.18-194.el5.img
title Windows Vista
rootnoverify (hd0,0)
chainloader +1
title Ubuntu
root (hd0,2)
# chainloader +1
kernel /boot/vmlinuz-2.6.32-25-generic ro root=/dev/sda3 rhgb quiet
initrd /boot/initrd.img-2.6.32-25-generic

I previously tried chainloader +1 but that failed. Vista loads fine. The vmlinuz and initrd files are there. I've tried (hd0,2)/boot/vmlinuz-2.6.32-25-generic but that also doesn't work. I'm out of ideas. I can think of two solutions that would be acceptable: fix GRUB on the CentOS partition to load Ubuntu, or switch the MBR to use GRUB 2 on the Ubuntu partition and hopefully I'll be able to load CentOS from there.

Thanks in advance.

November 20th, 2010, 01:06 PM
This is probably a difficulty of CentOS using legacy grub, and the ubuntu being on ext4 or something related to that.

The easiest way is to restore grub 2 from the ubuntu live CD and then reboot. Grub2 from ubuntu should nowhave taken over and you can use the command sudo update-grub to make sure it has found all OSs for its menu.

and http://ubuntuforums.org/showthread.php?t=1195275

November 20th, 2010, 08:29 PM
Thanks a lot! The first link (https://help.ubuntu.com/community/Grub2#Reinstalling%20GRUB%202) solved the issue with a few adjustments. For any who follow me:

Since I had access to CentOS and I could mount the Ubuntu partition I ignored the parts about the Live CD (also I didn't have one handy). I went with the chroot method which switched the root to the Ubuntu partition and from there I ran update-grub and grub-install. This switched GRUB 2 to be my bootloader and once I restarted I could boot Ubuntu but not CentOS, however that was solved by running update-grub.

Thanks again.

May 2nd, 2011, 09:47 PM
Helo Everybody with the same problem like described in first post.

I had similar problem but for some reason I had to stay with CentOS GRUB, so reinstallation of GRUB to Ubuntu version was not acceptable to me. After some experiments witch GRUB ( key 'e' during startup saves life time ) I make workaround solutions.

I copied from Ubuntu files "vmlinuz-...." and "initrd.img-...." to CentOS "/boot" directory. In file "/boot/grub/grub.cfg" I added lines:

title Ubuntu
root (hd0,2)
kernel /vmlinuz-.... root=/dev/sda2 ro quiet
initrd /initrd.img-....

"root (hd0,2)" pointed CentOS partition (counted from 0 - zero)
"/dev/sda2" pointed at Ubuntu partition (counted from 1)

Important was removing "/boot" string from line "kernel /boot/vmlinuz-...." and from line "initrd /initrd.img-....". With this string it did not work. I guess it have to be tested in every case.

I guess this solution is not very professional but I think it can help somebody.

Also I expect problems during/after weekly Ubuntu upgrade when kernel can be also upgraded.