2011/06/19

GRUB2: Window 7 + Ubuntu 11.04 + CentOS 5.6

THE STORIES:

Window 7 install first, then the Ubuntu 11.04, and then the CentOS 5.6.
This procedure makes Ubuntu entry lost.

Windows 7 - for some applications support Windows 7 only...
Ubuntu 11.04 - daily use
CentOS 5.6 - for some jobs dedicated to CentOS/RedHat

The harddisk allocated as below.

$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00070a7f

   Device Boot      Start           End            Blocks   Id   System
/dev/sda1   *              1       12749   102400000     7  HPFS/NTFS
/dev/sda2           12750       24315     92903895   83  Linux
/dev/sda3           24316       60801   293073795   83  Linux

Disk /dev/sdb: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c82de

Device Boot      Start           End            Blocks    Id   System
/dev/sdb1 * 1 13 104391 83 Linux /dev/sdb2 14 38913 312464250 8e Linux LVM

THE SOLUTIONS:


Recover GRUB2 for Ubuntu 11.04 first.

1. Insert Ubuntu 11.04 Live CD into your DVD/CDROM drive.
2. Boot from DVD/CDROM drive.
3. Recover the GRUB2

$ sudo mount /dev/sda3 /mnt
$ sudo grub-install --boot-directory=/mnt /dev/sda

4. Remove Live CD, and reboot

If success, the Ubuntu menu is back.
Otherwise, look for other methods to make it back. Such as Ubuntu Boot-Recover tools. Please google it, and install in Ubuntu 11.04 Live CD.

5. Modify /boot/grub/grub.cfg or /etc/grub.d/40_custom

$ sudo vim /boot/grub/grub.cfg

6. Insert menuentries for CentOS 5.6 and Window 7 in 40_custom section
      :
      :
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "CentOS 5.6 x86_64" {
        insmod ext2
        set root='(hd1,msdos1)'
        linux /vmlinuz-2.6.18-238.el5 ro quiet
        initrd /initrd-2.6.18-238.el5.img
}
menuentry "Windows 7" {
        set root='(hd0,msdos1)'
        chainloader +1
}
### END /etc/grub.d/40_custom ###
      :
      :

6.b
If you choose 40_custom, you have to update grub.cfg.
$ sudo update-grub


7. save and reboot.

THE RESULTS:
It works fine to me :)
Now, I can choose Ubuntu 11.04, CentOS 5.6 or Windows 7 from GRUB2 menu.

---

沒有留言: