Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This is really getting me down. I have Gentoo and Ubuntu, both with Grub2. Gentoo has a dedicated /boot partition, while Ubuntu does not. I have a menuentry in Gentoo's /etc/grub.d/40_custom to boot Ubuntu (and Ubuntu does boot OK).

Because Ubuntu comes with Grub I want to chainload into that one, instead of maintaining my entry which sets the root, kernel, initrd and stuff. This is what I have for the chainloader (Ubuntu is on /dev/sda4 and I have already installed Grub there):

menuentry 'Chainloader' {
    insmod chain
    set root=(hd0,4)
    chainloader +1
}

It is giving me error: Invalid signature and I found no solution available. Can someone point out something?

This is the result of </dev/sda4 head -c 512 | hd

00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200

This is the result of fdisk -l. /dev/sda1 is /boot of Gentoo, Gentoo is in /dev/sda2, Ubuntu is in /dev/sda4. Ubuntu's /boot is in /dev/sda4 too.

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 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: 0xe001152b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1           9       72261   83  Linux
/dev/sda2              10       13064   104864287+  8e  Linux LVM
/dev/sda4   *       18152       19457    10490445   83  Linux

There is no error with grub-install /dev/sda4 --no-floppy --force

/usr/sbin/grub-setup: warn: Attempting to install GRUB to a partition instead of the MBR.  This is a BAD idea..
/usr/sbin/grub-setup: warn: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
Installation finished. No error reported.
share|improve this question
    
Clearly you haven't installed a bootloader on /dev/sda4. Do you have more than one disk? What is your partition table? Please post the output of fdisk -l, and the messages from grub-install /dev/sda4 --no-floppy --force. –  Gilles Oct 15 '10 at 17:34
    
yes, I updated the question –  phunehehe Oct 17 '10 at 5:35

3 Answers 3

You can chainload GRUB2 from GRUB2, I just tried it the way you described and it works. However, the information you provided makes it look like the boot image did not get embedded in the MBR of the disk (or it wouldn't be all zeros).

I would try this, although it is not exactly using the GRUB2 from Ubuntu (just it's configuration file). You can create a menu entry in the Gentoo GRUB2 configuration file that loads the Ubuntu configuration file. There are two ways I see to do this.

The one I would use is with the normal command, which allows you to specify a config file to load for normal mode. If you go this route, there is a command called normal_exit that you could add as a custom item in your Ubuntu configuration which would allow you to return to your Gentoo configuration.

The other option is the configfile command, which lets you specify an alternate config file to load. It seems like it would be harder to "back out" of this option though.

More information on these commands can be found here.

share|improve this answer

The initial part of the boot up process consists of loading code from the first sector of the hard drive, the so called Master Boot Record (MBR). Normally, Grub is written into this first hard drive sector and not into the first sector of the partition holding /boot. However, you can normally change this during Linux install but in modern installation routines, this is often hidden.

You say that you have Grub installed into /dev/sda4, however your config looks correct and the error message you posted suggests, that Grub might not be installed correctly into the partition you want to chainload. You should boot into Gentoo, then chroot into the Ubuntu partition. Make sure that /boot now points correctly to the Ubuntu-/boot and not the Gentoo one! Now install Grub 2 into the first sector of the Ubuntu-Partition /dev/sda4: grub-install /dev/sda4 --no-floppy.

As always when fiddling with MBR and partitions, make sure you have a functional, up-to-date backup before you start.

share|improve this answer
    
does it make a difference if I boot into Ubuntu and run the grub-install? cos that's what I did and it doesn't work :( –  phunehehe Oct 14 '10 at 4:25
    
I thought you can not boot into Ubuntu because the chainloading doesn't work? But no, it shouldn't make a difference if you boot into Ubuntu or chroot into it. –  fschmitt Oct 14 '10 at 8:08
    
@phunehehe: The error message means that Grub hasn't found a bootloader signature in the first sector of /dev/sda4 (the last two bytes must be 0x55 0xaa). Could you post the output of </dev/sda4 head -c 512 | hd? –  Gilles Oct 14 '10 at 18:36
    
@Gilles: I added the result to the question. Doesn't look correct, does it? –  phunehehe Oct 15 '10 at 7:23
    
actually I have to run grub-install /dev/sda4 --no-floppy --force, otherwise there will be some complaints about blocklists –  phunehehe Oct 15 '10 at 7:24

Isn't sda4 going to be (hd0,3) in grub, or has this sort of thing changed in grub2?

share|improve this answer
    
yep, I'm sure /dev/sda4 will become (hd0,4) because that's what I have been using to boot Ubuntu –  phunehehe Oct 14 '10 at 18:12
3  
Yes, Grub 0.97 started counting harddisks and partitions with 0. Grub 2 still starts counting disks with 0 but starts counting partitions with 1. So /dev/sda4 is hd0,3 in Grub 0.97 and hd0,4 in Grub 2. –  fschmitt Oct 14 '10 at 18:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.