LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grub doesn't recognise logical partition until Ubuntu Hardy Heron boots up (https://www.linuxquestions.org/questions/linux-newbie-8/grub-doesnt-recognise-logical-partition-until-ubuntu-hardy-heron-boots-up-727068/)

wreckgar23 05-19-2009 10:15 AM

grub doesn't recognise logical partition until Ubuntu Hardy Heron boots up
 
I'm hoping this is an obvious question and that I'm not understanding something very basic!

I have 2 HDs. The first HD has a Windows install. The 2nd has a ubuntu 8.04.

The MBR of the first HD has a grub install. The actual grub menu.lst files etc. are on the 2nd HD

This all worked fine until I tried to install Ubuntu 9.04. (I know I should have upgraded through System -> Administration -> Software Sources instead of using a live CD - my mistake)

The installer created an extended partition on the 2nd HD for Ubuntu 9.04 and its swap space, and modified the MBR to point to grub files on a logical partition.

This gave me grub error 5 as stage 1.5. I was able to recover by reverting to the previous grub install.

I then tried to add 9.04 to the bottom of the grub menu, but it still gives me grub error 5

Basically, it seems that grub cannot recognise the logical partition until I boot the previous ubuntu install (8.04).

If I go to the grub command line from the grub menu (ie. on startup) only the first partition is available on the 2nd HD. However, if I boot up hardy and kick off grub from the command line, it recognises the logical partition(s).

I realise I could probably just remove the extended partition and start again, but I want to understand why I'm seeing the behaviour that I am, and am hoping that someone can explain this to me.

Thanks!

saikee 05-19-2009 12:07 PM

I for one cannot understand your problem.

If you say Grub doesn't recognise logical partitions you have to prove it with error message and post your information here.

Grub can see more logical partition than many parts of the kernel can!

As an example I have a disk with 130 partitions out of which 126 of them are logical. Fdisk can only display 60. cfdisk can be used to create up to 64 partitions. My 130 partitions were created by a script with sfdisk. Gparted is the only tool I know that can cross the 130 partitions barrier to create more.

Grub can see all of them and more importantly fire up any system in any of these logical partitions.

When I check the Grub manual Error 5 is "Partition Table invalid or corrupt". That means you may have inadvertently damaged the partition table of one of the disks. This should show up in Ubuntu terminal command
Code:

sudo fdisk -l

NeddySeagoon 05-19-2009 01:19 PM

wreckgar23,

Grub is claiming (from info grub)
Code:

5 : Partition table invalid or corrupt
    This error is returned if the sanity checks on the integrity of the
    partition table fail. This is a bad sign.

What does
Code:

fdisk -l
show ?

I presume you are using MSDOS Partition Tables?
If you have swapped to GPT (unlikely), I don't know if grub supports that yet.

Does your three parts of grub have different versions?
Thats known to cause issues from time to time.

wreckgar23 05-19-2009 03:43 PM

Thanks for the responses.

To hopefully clarify this:

From the grub menu on bootup, if I enter the grub command line and type the following...

root (hd1,[tab key]

... it is auto-completed as

root (hd1,0)

However, if I load up Hardy Heron and invoke grub from the terminal and do the same, I get the following

Possible partitions are:
Partition num: 0, Filesystem type is ext2fs, partition type 0x83
Partition num: 4, Filesystem type is ext2fs, partition type 0x83
Partition num: 5, Filesystem type unknown, partition type 0x82
Partition num: 6, Filesystem type unknown, partition type 0x82

So my question is why is there this different behaviour?

btw here is the output of fdisk -l

Disk /dev/sda: 123.5 GB, 123522416640 bytes
255 heads, 63 sectors/track, 15017 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe63f1ecc

Device Boot Start End Blocks Id System
/dev/sda1 * 1 15016 120615988+ 7 HPFS/NTFS

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

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 38399 308439936 83 Linux
/dev/sdb2 38400 38913 4128705 5 Extended
/dev/sdb5 38400 38703 2441817 83 Linux
/dev/sdb6 38704 38725 176683+ 82 Linux swap / Solaris
/dev/sdb7 38726 38913 1510078+ 82 Linux swap / Solaris

wreckgar23 05-19-2009 03:57 PM

In answer to NeddySeagoon

Ubuntu 8.04 uses grub 0.97-29ubuntu21
Ubuntu 9.04 uses grub 0.97-29ubuntu53

It is the 9.04 installer that has created the extended partition and its logical partitions. It also gave me grub error 5 at stage 1.5 when I rebooted!

I had to revert to the 8.04 install's grub to recover. I can access the logical partition from ubuntu 8.04. But trying to modify 8.04's grub menu so that it loads 9.04 doesn't work for me. I get the grub error 5 whenever I try to refer to it. It doesn't seem like there is a problem with the partition table - maybe you can see one from the output of fdisk?

syg00 05-19-2009 05:11 PM

Let me guess - one IDE disk and one S-ATA disk ???

saikee 05-19-2009 05:34 PM

Have you tried the command to display all the partition of the 1st disk by
Code:

geometry (hd0)
for the 2nd disk
Code:

geometry (hd1)
I couldn't see anything wrong with the partition table myself.

It is impossible to tell the difference here as potentially there are two Linux, in sdb1 and sdb5 respectively so there are two versions of Grub implementation of "Grub shell". The Grub in the MBR was sourced from one of the Linux to provide a Grub prompt which is a stripped version of a Grub shell. The former does not have access to a kernel (as none has been booted) while the latter has. Therefore it is pointless to expect them behave identically.

wreckgar23 05-20-2009 05:00 AM

Thanks again for all the responses

It's clear from saikee's original response that grub should have no problem recognising logical partitions. In my case it does, but these are partitions created by the Ubuntu 9.04 installer.

I was puzzled by the different behaviour of grub depending upon whether its invoked from the bootup menu or from the terminal, but I realise now I'm assuming that I'm using the same grub in both cases, which probably isn't true. Not all the same commands aren't available, for example.

It's not true however to say that I'm using the grub from 2 different "Linux" however - the one on the bootup menu and the one from the terminal are both from 8.04

Both hard drives are IDE. I don't have the geometry command available on the command-line or in the synaptic package manager

I think that I have to take grubs word for it at bootup that the partition table is invalid or corrupt. I'll see if there is a known defect in the 9.04 installer

saikee 05-20-2009 05:13 AM

The command
Code:

geometry (hd0)
is a Grub command available in any Grub prompt. You will see it as part of the command set if you type "help" at the Grub prompt.

That is a very useful command because that is exactly what Grub sees in the first bootable disk. In other word you get the word directly from the horse's mouth!

If you have installed Ubuntu 8.04 twice then the two Grub are the same but the version before and after the Linux has been boot is different.

As a simple example and you can try it any time.

If you are booting to an internal hard disk and has a USB disk (pen drive or external hard disk) Grub will not be able to see it in a Grub prompt before a Linux has been booted. Grub can only see one "USB" device if you force the Bios to boot to that USB device.

However after the Linux has been booted Grub can see all the disks.

The above shows Grub is different before and after a Linux has been booted. In the former the hardware information is supplied by the Bios whereas in the latter Grub gets it from the kernel.

syg00 05-20-2009 05:27 AM

Quote:

Originally Posted by wreckgar23 (Post 3546771)
It's clear from saikee's original response that grub should have no problem recognising logical partitions. In my case it does, but these are partitions created by the Ubuntu 9.04 installer.
...
It's not true however to say that I'm using the grub from 2 different "Linux" however - the one on the bootup menu and the one from the terminal are both from 8.04

Ahhh - I hadn't read this closely enough before.
Are the Jaunty (9.04) partitions ext3 (or ext4) ?. If so, they will have been created with the larger inode - you'll (probably) need the grub from Jaunty that has been patched to recognise this.
I bumped into this with Fedora 10 - Intrepid grub couldn't handle it, but Fedora had a patched grub.

wreckgar23 05-20-2009 05:30 AM

From the terminal

Code:

grub> geometry (hd1)
drive 0x81: C/H/S = 38913/255/63, The number of sectors = 625142448, /dev/sdb
  Partition num: 0,  Filesystem type is ext2fs, partition type 0x83
  Partition num: 4,  Filesystem type is ext2fs, partition type 0x83
  Partition num: 5,  Filesystem type unknown, partition type 0x82
  Partition num: 6,  Filesystem type unknown, partition type 0x82

From the bootup menu

Code:

grub> geometry (hd1)
  drive 0x81: C/H/S = 1024/255/63, The number of sectors = 625142448, LBA
Partition num: 0,  Filesystem type is ext2fs, partition type 0x83

I've marked the differences, but don't know what they mean yet!

wreckgar23 05-20-2009 05:50 AM

Thanks syg00. I wonder if I end up with a chicken-and-egg type situation here though. Jaunty was installed to the logical partition that its installer created. I had to revert to Hardy's grub because I would get grub error 5 at stage 1.5, which is the same behaviour I get now if I try to load Jaunty from the boot menu ie. the logical partition it resides on can't be recognised at bootup.

I'm assuming that the Jaunty installer has given me a version of grub that can recognise the file systems it has created! It's on a logical partition, though, and I can only rely upon the primary partition for now.

Hopefully I can just copy the grub directory over from the logical to the physical partition. I should first verify with the liveCD that the Jaunty installer has created ext4 filesystems - as seems likely.

Thanks everyone

saikee 05-20-2009 06:23 AM

syg00 got a valid point.

The legacy Grub 0.97 was declared no longer maintained by the GNU/Grub team about 3 years ago but this is still the most widely version. The Grub2 has few customer because it has next to nil documentation.

Ext4 was born after Grub 0.97 so it unlikely Grub can read its content. Linux distros intending to run Ext4 filing system may need to patch their versions of Grub.

I haven't used Ext4 much and didn't get into too much bother with it. Ext4 partitions cannot be mounted by Linux with kernel older than 2.6.28 so it is not easy to rescue.

It is possible if the OP has an Ext4 partition then it will be regarded by Grub as an unknown filing system. If this is the case then an unpatched normal Grub may have difficulty to boot a Ext4 partition directly as Grub needs to get inside to find the kernel and ramdisk files.

Not able to read a partition doesn't stop Grub from booting it. Grub never understand a ntfs partition but that it can chainload any or all of the Win2k, Xp, Vista and Win7.

syg00 05-20-2009 06:28 AM

ext3 (not just ext4) created by newer systems is affected by this as well. Have a look at this for some background.

wreckgar23 05-20-2009 07:28 AM

According to the Jaunty liveCD, my filesystem is ext3. ext3 is recognised by Hardy as well.

I've since remembered that while I was trying to recover from the original grub error that I had after installing Jaunty, I ran Hardy's fdisk on the hard drive to "repair" the partition table. This may well have not been a good move, especially considering that Jaunty may have created a file system of a type that Hardy doesn't support.

Maybe because of this, the Jaunty version of grub, booted from a cd, still only recognises the one partition on my linux hard drive.

Having messed about with the partition table, I can't reliably recover the Jaunty install. I need to remove the existing extended partition and try again. At least I have learnt that grub should support logical partitions and to be wary of installers' default options and of new file systems as they come along.

I appreciate everyone taking the time to answer my questions, so thanks. The only other thing I'm wondering about now is whether it's possible that some BIOS issue could cause grub to not recognise the logical partitions? The number of cylinders reported by grub from the terminal is a great deal bigger than from the bootup menu grub command line


All times are GMT -5. The time now is 12:23 AM.