Updating GRUB

I’ve added a second hard drive (SATA) to my desktop machine with Ubuntu installed on it, but I can’t seem to be able to update GRUB to enable booting from it without disconnecting my main (openSUSE/Windows) hard drive. Back when I used to use Ubuntu as my main OS, I used update-grub, but that doesn’t work in openSUSE. Say the command is not found. Is there another way? The Ubuntu HD also has GRUB installed, but I’d rather use the openSUSE GRUB, as I don’t like the text only GRUB of Ubuntu.

update-grub is a Grub2 specific command. openSUSE uses legacy Grub and doesn’t have that command. Ubuntu’s Grub is not text only at all. In fact, it could look nicer thant Legacy Grub as you can easily customize it as you like with any picture and resolution. Under Ubuntu you can edit the file /etc/grub.d/05_debian_theme and replace the line :

for i in /boot/grub/`basename ${WALLPAPER}` ${WALLPAPER} ; do

with (for example) :

for i in /usr/local/share/images/mysplash.jpg /boot/grub/`basename ${WALLPAPER}` ${WALLPAPER} ; do

where /usr/local/share/images/mysplash.jpg is the absolute path of the picture you want to use.
Then rerun update-grub.

If you want to use openSUSE grub, you can run the command grub to start the grub shell and then install grub in MBR with

root (hd0,x)
setup (hd0)

where (hd0,x) is the partition where /boot/grub is located.
Be aware the in Legacy grub syntax :
(hd0,0) -> sda1
(hd0,1) -> sda2
etc.
while in Grub 2 Syntax
(hd0,1) -> sda1
(hd0,2) -> sda2
etc.

I ran that command, but still couldn’t get openSUSE’s GRUB to recognize Ubuntu. I got the output, which from what I can understand, there were no errors.

    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 (hd0,1)
 Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  17 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,1)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.

grub> 

The main HD is mounted at sda while the 2nd one is at sdb

That’s not what I said. Ubuntu’s Grub recognizes openSUSE. But openSUSE’s doesn’t recognize Ubuntu. You have to add Ubuntu’s entries manually to /boot/grub/menu.lst under openSUSE if you want to boot Ubuntu’s kernel directly or if you want to chainload Ubuntu’s Grub. You can chainload Grub in both ways. For example, to chainload Ubuntu’s Grub installed in the MBR on the second HD, you would add to /boot/grub/menu.lst (in openSUSE):

Title Ubuntu Boot menu
root (hd1)
chainloader +1

if it’s in the bootsector of the second partition of the first HD, you would use:

Title Ubuntu Boot menu
root (hd0,1)
chainloader +1

Now the other possibilities should be easy to guess.

Follow this by @swerdna
HowTo Multiboot Ubuntu from openSUSE using the GRUB bootloader

I successfully chainloaded Ubuntu (Actually Kubuntu 10.10 with the Trinity Desktop Environment) just to confirm I did it OK I posted the contents of my boot.lst

# Modified by YaST2. Last modification on Sat Oct 16 15:58:22 EST 2010
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# Configure custom boot parameters for updated kernels in /etc/sysconfig/bootloader

default 0
timeout 8
gfxmenu (hd0,1)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 11.3
    root (hd0,1)
    kernel /boot/vmlinuz-2.6.34.7-0.4-default root=/dev/disk/by-id/ata-WDC_WD6400AACS-00G8B1_WD-WCAUF2377173-part2 resume=/dev/disk/by-id/ata-WDC_WD6400AACS-00G8B1_WD-WCAUF2377173-part3 splash=silent quiet showopts vga=0x31a
    initrd /boot/initrd-2.6.34.7-0.4-default

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title openSUSE 11.3 - Failsafe
    root (hd0,1)
    kernel /boot/vmlinuz-2.6.34.7-0.4-default root=/dev/disk/by-id/ata-WDC_WD6400AACS-00G8B1_WD-WCAUF2377173-part2 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe vga=0x31a
    initrd /boot/initrd-2.6.34.7-0.4-default

###Don't change this comment - YaST2 identifier: Original name: windows###
title Windows 7 Home Premium
    rootnoverify (hd0,0)
    chainloader +1

###Don't change this comment - YaST2 identifier: Original name: ubuntu###
title Ubuntu Boot menu
    root (hd1)
    chainloader +1

Is Kubuntu on a different HD?

openSUSE and Windows are on one HD, while Kubuntu is on a separate one all to itself. I did that because I wasn’t bothered with resizing my openSUSE partition. They all have approx. 320 GB each, openSUSE and Windows each have half of a 640 GB disk, and the Kubuntu disk is 320 GB.

Just making sure I wasn’t cracking up :wink:

Hi i have ubuntu 10.04 installed on my machine and was working perfectly, but after I install opensuse 11.2 It was not showing the Ubuntu on booting my machine. Afterward reading your post I changed my menu.lst file but the problem is that when I choose Ubuntu in the boot menu. It gives me error that invalid file format ext2fs.

here is my menu.lst file

 
# Modified by YaST2. Last modification on Tue Nov 16 15:44:21 IST 2010
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# Configure custom boot parameters for updated kernels in /etc/sysconfig/bootloader

default 0
timeout 8
##YaST - generic_mbr
gfxmenu (hd0,8)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original name: linux###
title Desktop -- openSUSE 11.2 - 2.6.31.14-0.4
    root (hd0,8)
    kernel /boot/vmlinuz-2.6.31.14-0.4-desktop root=/dev/disk/by-id/ata-ST3500418AS_9VMGXGPS-part9 resume=/dev/disk/by-id/ata-ST3500418AS_9VMGXGPS-part8 splash=silent quiet showopts vga=0x346
    initrd /boot/initrd-2.6.31.14-0.4-desktop

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 11.2 - 2.6.31.14-0.4
    root (hd0,8)
    kernel /boot/vmlinuz-2.6.31.14-0.4-desktop root=/dev/disk/by-id/ata-ST3500418AS_9VMGXGPS-part9 showopts apm=off noresume nosmp maxcpus=0 edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 x11failsafe vga=0x346
    initrd /boot/initrd-2.6.31.14-0.4-desktop

###Don't change this comment - YaST2 identifier: Original name: windows 1###
title windows 1
    rootnoverify (hd0,0)
    chainloader +1

###Don't change this comment - YaST2 identifier: Original name: windows 2###
title windows 2
    rootnoverify (hd0,1)
    chainloader +1

###Don't change this comment - YaST2 identifier: Original name: Ubuntu###
title Ubuntu
    root (hd0,6)
    chainloader +1


and here is the fdisk -l command result


Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x839e922a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         262     2096128    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2             262        8094    62914584    7  HPFS/NTFS
/dev/sda3   *        8094       60802   423372801    f  W95 Ext'd (LBA)
/dev/sda5            8094       44187   289916928    7  HPFS/NTFS
/dev/sda6           50562       51076     4129792   82  Linux swap / Solaris
/dev/sda7           51076       60802    78124032   83  Linux
/dev/sda8           44188       44818     5068476   82  Linux swap / Solaris
/dev/sda9           44819       50561    46130616   83  Linux

/dev/sda7 contains the Ubuntu Partition as I mounted it and was able to view the contents of my ubuntu partition. Also here is the grub.cfg file of my ubuntu 10.04


#
# 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 $prefix/grubenv ]; then
  load_env
fi
set default="0"
if  ${prev_saved_entry} ]; then
  set saved_entry=${prev_saved_entry}
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if  -z ${boot_once} ]; then
    saved_entry=${chosen}
    save_env saved_entry
  fi
}

function recordfail {
  set recordfail=1
  if  -n ${have_grubenv} ]; then if  -z ${boot_once} ]; then save_env recordfail; fi; fi
}
insmod ext2
set root='(hd0,7)'
search --no-floppy --fs-uuid --set 8efe510d-81e8-4412-96fc-39d75fea7ab6
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
insmod ext2
set root='(hd0,7)'
search --no-floppy --fs-uuid --set 8efe510d-81e8-4412-96fc-39d75fea7ab6
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
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/light-gray
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.32-25-generic' --class ubuntu --class gnu-linux --class gnu --class os {
	recordfail
	insmod ext2
	set root='(hd0,7)'
	search --no-floppy --fs-uuid --set 8efe510d-81e8-4412-96fc-39d75fea7ab6
	linux	/boot/vmlinuz-2.6.32-25-generic root=UUID=8efe510d-81e8-4412-96fc-39d75fea7ab6 ro   quiet splash
	initrd	/boot/initrd.img-2.6.32-25-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-25-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
	recordfail
	insmod ext2
	set root='(hd0,7)'
	search --no-floppy --fs-uuid --set 8efe510d-81e8-4412-96fc-39d75fea7ab6
	echo	'Loading Linux 2.6.32-25-generic ...'
	linux	/boot/vmlinuz-2.6.32-25-generic root=UUID=8efe510d-81e8-4412-96fc-39d75fea7ab6 ro single 
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initrd.img-2.6.32-25-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-21-generic' --class ubuntu --class gnu-linux --class gnu --class os {
	recordfail
	insmod ext2
	set root='(hd0,7)'
	search --no-floppy --fs-uuid --set 8efe510d-81e8-4412-96fc-39d75fea7ab6
	linux	/boot/vmlinuz-2.6.32-21-generic root=UUID=8efe510d-81e8-4412-96fc-39d75fea7ab6 ro   quiet splash
	initrd	/boot/initrd.img-2.6.32-21-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-21-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
	recordfail
	insmod ext2
	set root='(hd0,7)'
	search --no-floppy --fs-uuid --set 8efe510d-81e8-4412-96fc-39d75fea7ab6
	echo	'Loading Linux 2.6.32-21-generic ...'
	linux	/boot/vmlinuz-2.6.32-21-generic root=UUID=8efe510d-81e8-4412-96fc-39d75fea7ab6 ro single 
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initrd.img-2.6.32-21-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
	insmod ext2
	set root='(hd0,7)'
	search --no-floppy --fs-uuid --set 8efe510d-81e8-4412-96fc-39d75fea7ab6
	linux16	/boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
	insmod ext2
	set root='(hd0,7)'
	search --no-floppy --fs-uuid --set 8efe510d-81e8-4412-96fc-39d75fea7ab6
	linux16	/boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sda1)" {
	insmod ntfs
	set root='(hd0,1)'
	search --no-floppy --fs-uuid --set deba0a01ba09d745
	chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### 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.
### END /etc/grub.d/40_custom ###



replace (hd0,7) with (hd0,6) everywhere in /boot/grub/menu.lst.

The entry below will only work if Grub2 is installed in Ubuntu’s root partition (sda7).

###Don't change this comment - YaST2 identifier: Original name: Ubuntu###
title Ubuntu
    root (hd0,6)
    chainloader +1

Ubuntu’s default is to install it in MBR, and openSUSE setup did more likely overwrite it with a generic bootcode. That’s a bad practice to please Windows users.

If you want to chainload Ubuntu’s Grub, install it in the bootsector of Ubuntu’s root partition. Under Ubuntu, type:

sudo grub-install /dev/sda7
then run
sudo update-grub

That should do it.

Thanks a lot it worked.

I din’t tried updating the grub. I changed the menu.lst file using the script provided by you and everything is working fine. Thanks once again:)