GRUB Error 17 when extra hard drive not attached

I recently installed openSUSE 11.4 on another hard disk of my 11.3 machine. I have another drive in my computer that is used solely for extra storage. Before installing 11.4 I could boot my computer with or without the drive installed, but now if I try to boot without it I get Error 17 from GRUB. I don’t understand this as there is nothing on that drive that should be needed by boot and I can find nothing in the GRUB configuration that references the drive.

I am getting ready to clear the whole system for a fresh install anyways, but it would be nice to know for future knowledge what is causing it.

Please show the output of

su -c 'fdisk -l'

then we see what you have and do not have to talk about vague things like “another disk”.

Also the output of

su -c 'cat /boot/grub/menu.lst'

might support what you say about you saying “I can find nothing in the GRUB configuration that references the drive”".

In short: we need facts, not stories.

A possible explanation is that when you installed openSUSE, your external disk was the first BIOS drive (hd0) and your internal drive the second one (hd1). So Grub was installed and set to boot from hd1. When you remove the external disk, hd1 becomes hd0 and the bootloader doesn’t find its boot drive anymore. Open the file /boot/grub/menu.lst and replace any occurence of hd1 with hd0 in this file, then change the boot order in the BIOS and give you internal drive the higher priority. No need to reinstall the system.

I think that is actually the problem. menu.lst lists the boot drive as (hd2,0) and when I remove that one drive it changes the boot device order like you said. I assumed that (hdx, y) would correlate with /dev/sda, b, c, etc, but the dev listing is not in the same order as they are in the BIOS.

When you pull a drive and then plug it in again
You’ll need to set the boot order in BIOS again because everything moves

I didn’t have a chance to reply earlier, but I tried changing the boot order in BIOS and the (hdx, y) in grub and it didn’t work. I don’t understand this, the drive only has a backup of my home folder on it.

Here are the outputs of the commands asked for above:

fdisk -l

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x84eeb34c

Device Boot Start End Blocks Id System
/dev/sda1 2048 307202047 153600000 83 Linux
/dev/sda2 307204096 512004095 102400000 83 Linux

Disk /dev/sdb: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders, total 390721968 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a6227

Device Boot Start End Blocks Id System
/dev/sdb1 2048 390721535 195359744 83 Linux

Disk /dev/sdc: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders, total 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfdfaf88e

Device Boot Start End Blocks Id System
/dev/sdc1 * 63 83907494 41953716 83 Linux
/dev/sdc2 83907495 713061089 314576797+ 83 Linux
/dev/sdc3 713061090 1132486109 209712510 83 Linux
/dev/sdc4 1132486110 1145065004 6289447+ 82 Linux swap / Solaris

Disk /dev/sdd: 2097 MB, 2097152000 bytes
66 heads, 63 sectors/track, 985 cylinders, total 4096000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdd1 * 123 4095615 2047746+ 6 FAT16

The device in question is the 750GB one.

cat /boot/grub/menu.lst

Modified by YaST2. Last modification on Mon May 9 03:35:18 EDT 2011

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 (hd2,0)/boot/message

###Don’t change this comment - YaST2 identifier: Original name: linux###
title Desktop – openSUSE 11.4 - 2.6.37.1-1.2
root (hd2,0)
kernel /boot/vmlinuz-2.6.37.1-1.2-desktop root=/dev/disk/by-id/ata-ST3200822AS_3LJ3SKZM-part1 resume=/dev/disk/by-id/ata-WDC_WD6402AAEX-00Z3A0_WD-WCATR0122404-part4 splash=silent quiet showopts vga=0x314
initrd /boot/initrd-2.6.37.1-1.2-desktop

###Don’t change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe – openSUSE 11.4 - 2.6.37.1-1.2
root (hd2,0)
kernel /boot/vmlinuz-2.6.37.1-1.2-desktop root=/dev/disk/by-id/ata-ST3200822AS_3LJ3SKZM-part1 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe vga=0x314
initrd /boot/initrd-2.6.37.1-1.2-desktop

This your suse device correct?

Disk /dev/sdc: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders, total 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfdfaf88e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          63    83907494    41953716   83  Linux
/dev/sdc2        83907495   713061089   314576797+  83  Linux
/dev/sdc3       713061090  1132486109   209712510   83  Linux
/dev/sdc4      1132486110  1145065004     6289447+  82  Linux swap / Solaris

But which HD was first in the BIOS with SUSE as sdc when you installed?

11.4 is installed on the 200GB disk. When I installed 11.4 the 640GB one was first as it was the system disk for 11.3. It was the only disk installed when I installed 11.2 (which I later upgraded to 11.3), and I was able to add and remove any drive I wanted until I installed 11.4.

But you see this from the menu.lst

-WDC_WD6402AAEX-00Z3A0

I read that to be WD640
or am I wrong

No you are right, and I saw that, and I am not sure why that resume from WD640 is there, but in any case the is no mention of of the 750GB Hitachi in the menu.lst and that is the drive that I want to remove.

Let me explain what I suspect to be a bug.
On my machine I have 2 internal HD’s
320 GB is first in boot order in BIOS
500 GB is second in BIOS

I installed 11.4 to the 500 GB
But SUSE see it as sda and so the menu entry is (hd0) but really it should be (hd1)
The average user is not going to notice this and even if they do, finding the location to correct it is difficult. But here is where:
http://dl.dropbox.com/u/10573557/Bootloader%20HD%20Order/bootloader-main.png
http://dl.dropbox.com/u/10573557/Bootloader%20HD%20Order/bootloader-details.png
http://dl.dropbox.com/u/10573557/Bootloader%20HD%20Order/bootloader-details2.png

Anyway, it matters not to me because I use Mint 10’s grub 2 to boot my 11.4 install

If it becomes too confusing I recommend a small partition set aside for a install of a distro that uses grub 2 (eg: Mint or Ubuntu) It only needs to be big enough to install so 7 GB is plenty. But it installs grub to the MBR of (hd0) so remember to keep that HD as the first device

Another option is to boot SUSE and install updategrub (not to be confused with the update-grub)
updategrub for openSUSE Legacy Grub (not update-grub!)

O.K., one thing different on my system is that instead of “boot from root partition” being checked, “boot from MBR” is checked. But also, menu.lst shows the boot device as (hd2,0), which should be the 3rd hard drive, and in the bios and the boot loader configuration in yast it is the 3rd drive. So should I change the order in the boot loader configuration? I am a bit leery to change this as if it doesn’t work and I can’t boot the system i am not sure how to fix it.

(hd2) is the 3rd HD

It’s like this

(hd0)
(hd1)
(hd2)

I advised earlier of an easy fix using Grub 2

@caf4926
Hmmm … When you install openSUSE, grub will scan for devices and create /boot/grub/device.map where ‘logically’, (hd0) should be mapped to sda and (hd1) to sdb … unless the device.map already exists - which means it could have been generated before and passed to grub as an argument. So it is not impossible that the setup decides to map the drive on which you installed the system as sda before installing the bootloader. In fact, it doesn’t matter since the names ‘sda’, ‘sdb’ are irrelevant and widely unreliable. When the second HD is involved - and every time when mixing IDE and SATA disks - it often happens that what appeared to be sda during setup shows up as sdb at the next boot and vice versa.

However people should avoid to:

  • install the system on an internal disk while an external disk is plugged in.
  • update the kernel when an external disk is plugged in

If we’re looking for a bug, I suggest taking a look at /usr/lib/perl5/vendor_perl/5.12.1/Bootloader/Tools.pm, used by /sbin/update-bootloader to add/remove Grub entries during setup and after a kernel update. If an external drive - which was not present at installation time - becomes the first BIOS drive before a kernel update, the device.map won’t reflect the boot order anymore. I don’t know why /usr/lib/bootloader/bootloader_entry (calling /sbin/update-bootlader) looks at the device.map but it does:

# grep -C 3 'device.map' /usr/lib/bootloader/bootloader_entry
ls -l /dev/{[hs]d[ab]?,md[0-3],.udev,disk/by-*} 2>/dev/null || ls -l /dev | grep ^b
echo

device_map="/boot/grub/device.map"
if  -e $device_map ] ; then
        echo "device.map:"
        cat $device_map
        echo
fi
) >> $logname

Well, it looks like it just prints the device.map in a log. But Bootloader/Tools.pm also looks at the udev map, which will be different if an external drive becomes the first BIOS device. The consequence is a mess in Grub menu ending up with a boot entry containing the wrong HD - no matter which syntax you use in this file since the entry will be rewritten according to a wrong device mapping - whether it comes from reading device.map or from udev.

IMHO a permanent solution would be to bring udev to handle USB drives differently and/or people to stop using external drives as if they were internal ones.

Mate,

I’ll have a look at this later when I’m not busy.

I can tell you however.

  1. I’m not confused.
  2. I know the installer only gets confused when I install SUSE to (hd1). If I install to (hd0) it figures it out OK

You see the installer sees (hd0) as sda in the partitioner
But in the bootloader install details it has the HD’s in the wrong order here
http://dl.dropbox.com/u/10573557/Bootloader%20HD%20Order/bootloader-details2.png

  1. It’s not a problem for me BTW. I can switch to my modified menu and use that. But currently I use Grub 2

Yes, I’m aware of this problem. I’ve already experienced the situation.

I’m aware of that too. :wink:

@hito_kiri

You can run the halinfo script posted here Displaying partitions infos from hal daemon with the command:

halinfo -uV

That would show everyhting about your drives.
And please post the output of this command:

cat /boot/grub/device.map

Once you’ve edited your Grub menu properly, you should change the BIOS order so that the internal drive boots first. That might not always help however. So I strongly recommand to unplug you external drive before doing a kernel update.