Installing GRUB after removing HDD

First off, here’s a printout of the hardrives on my system.


Disk /dev/sda: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x87df9c9a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1275    10241406   27  Unknown
/dev/sda2   *        1276        7649    51199155    7  HPFS/NTFS
/dev/sda3            7650       77825   563688720    5  Extended
/dev/sda5            7650        9474    14659281   83  Linux
/dev/sda6            9475       10448     7823623+  83  Linux
/dev/sda7           10449       77825   541205721   83  Linux

Disk /dev/sdb: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x9dc96e9e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1           4       32098+  de  Dell Utility
/dev/sdb2   *           5        4865    39045982+   f  W95 Ext'd (LBA)
/dev/sdb5               5        4865    39044096    7  HPFS/NTFS

Linux is installed on sda5, 6, 7 as you can see. Windows is on sda2, and sda1 is the EISA partition that came with my computer for resetting back to factory settings. sdb is a secondary hardrive used for backing up files. When I installed SUSE 11.1, GRUB was installed onto sdb for some reason. This is the HDD that my computer boots to during startup. I removed the HDD without remembering that GRUB was on it and during startup it went right to XP. So I booted from LiveCD, opened up a terminal and did the following:


# mkdir /media/root
# mount /dev/sda5 /media/root
# grub-install --root-directory=/media/root /dev/sda#

In place of #, I tried sda5 and sda1 when sda5 didn’t work. Either way, this pops up the GRUB installer window. I tried selecting boot from MBR when I selected both sda5 and sda1, but either way, I get the same error during reboot after it says loading GRUB.

(hd1,4)/boot/message: file not found

Then it goes to an MS-DOS looking boot menu that lists OpenSUSE 11.1 and Windows. I try selecting either one and I get the error:

Error 18: Selected cylinder exceeds max. supported by BIOS.

I have a feeling it’s my EISA partition, which is at the beginning of my HDD that’s screwing stuff up by taking up all the cylinders at the beginning of my HDD, but then again, how does the Windows boot loader work then? BTW, I want to remove the secondary HDD, but I need to first get GRUB working from sda.

HowTo Boot into openSUSE when it won’t Boot from the Grub Code on the Hard Drive

I tried…

Broken Grub menu: boot to the menu, drop to a console and boot openSUSE direct

…and it seemed like it booted, but it didn’t go to the GUI. It ended up asking me for linux login. I tried typing but couldn’t. As a note, I have to add noacpi acpi=off to my boot menu to make the mouse and keyboard work.

I tried…

Reinstall Grub in the Master Boot Record and link it to the existing Grub menu in openSUSE

… and it caused the same error as the first time. Error 18: file not found. BIOS doesn’t support booting from above such and such cylinder.

I tried…

Boot from the SuperGrub Disk: see Super Grub Disk Homepage

… and again got the same error as originally

I couldn’t try the last option in your link because I could never boot into SUSE without that second hard drive connected. I assume if I choose MBR in YaST in my current configuration (with the sdb still attached) it will just put it in the MBR of sdb, which wouldn’t get me anywhere.

I feel like I need to get GRUB installed at the beginning of my hard drive. Is there any way I can move that EISA partition at the beginning of the hard drive to that secondary hard drive in SUSE?

I doubt it the recovery partition that’s causing the problem.

Ideally you would keep the other HD (sdb) in place, and have grub on there - as you say it has been. This is better IMO as it helps preserve the integrity of sda

The CRUCIAL thing is boot order, and in the case of both being SATA drives you may actually have to change the order they are plugged in to the mobo. If sdb is a pata/ide drive it’s ok, but it needs to be Master on the jumper.

Principle ideas here:
Partitioning/Install Guide - openSUSE Forums

sdb is IDE and the jumper is set to cable-select. If you’re saying that sdb has to stay, though, then I guess I don’t have to change anything since SUSE loads fine with the second hard drive connected. I’ll just keep the disk on as a place to make backups and stop fudging with the bootloader.

Thanks for the help.

Set sdb to Master!
Then first in the boot order and if it were me, I would seriously consider re-installing suse.
Double check that grub is going to MBR on sdb

This pic shows it (though it has sda not sdb)
http://files.myopera.com/carl4926/albums/671478/19.png

Double check back here again at the summary that is shows sdb MBR and hasn’t reverted back to something else, if it does there is something wrong in bios settings
http://files.myopera.com/carl4926/albums/671478/16.png

I could set sdb to master and it already is first in line for booting.

As for reinstalling SUSE, I’ll consider it, but I’ve already lost so much productivity dealing with the first install, I really don’t think I have the time to go at it again (especially if it’s as painful as the first install). Are the consequences dire? GRUB is already on MBR of sdb, isn’t it?

You didn’t say what kind of drive sda was, is it SATA? If sda is SATA and sdb is PATA, that would explain why the system reverted to sda when sdb was removed. When you have a mixed system like that, there can also be a preferred booting order where PATA overrrides SATA if installed.

When you removed sdb, it reverted to the original setup. So situation at that point is one where you have installed Linux but have no GRUB at all. So the original Windows bootloader took over.

You didn’t say what the mount points of sda[567] are. Those are important. When you install GRUB, using a rescue CD, /boot must be mounted in the same relative position as it would be when running. I suspect that 5 is / and 6 is boot, but you would have to look at /etc/fstab (on sda?) to tell. Then what you have to do is:

mount /dev/sda5 /media/root
mount /dev/sda6 /media/root/boot
grub-install blah blah

This stuff:

…but either way, I get the same error during reboot after it says loading GRUB.

(hd1,4)/boot/message: file not found

Then it goes to an MS-DOS looking boot menu that lists OpenSUSE 11.1 and Windows. I try selecting either one and I get the error:

Error 18: Selected cylinder exceeds max. supported by BIOS.
Seems to me to indicate that you’ve put the Grub boot code for sda onto a high partition rather than in the MBR. Maybe you could try an experiment to see if the setup is at all conducive to booting off of sda. If the sdb is disconnected (pull drive power cable), does a grub menu at all come up when u boot sda or does it go straight to windows bootloader (I know you said something about that but I’m a bit lost)? i.e. when you get the “msdos looking menu”, if you press Escape, what happens?

Ah yes, re Swerdna’s point, the last line cannot be business as usual. You should use:

grub-install --root-directory=/media/root /dev/sda

not a partition. This will install in the MBR.

You didn’t say what kind of drive sda was, is it SATA?

sda is SATA, sdb is IDE

You didn’t say what the mount points of sda[567] are.

sda5 is /
sda6 is swap
sda7 is /home

I didn’t create a partition for /boot. Sources I checked didn’t list it as necessary and it wasn’t mentioned in another installation thread I was talking in.

mount /dev/sda5 /media/root
mount /dev/sda6 /media/root/boot
grub-install blah blah…
grub-install --root-directory=/media/root /dev/sda

I took these steps except I didn’t mount /boot since I don’t have a separate partition for it. Do I need to mount the /boot directory or something?

Seems to me to indicate that you’ve put the Grub boot code for sda onto a high partition rather than in the MBR.

Yes, this is certainly the case. I remember checking off MBR during install, but it must have put it in MBR of sdb instead of sda. As previously discussed, I tried to reinstall grub on sda with sdb disconnected, but I get the same error. I believe I’ll try ken_yap’s suggestion of installing grub to /dev/sda instead of any particular partition and see what that does.

Let us know how it goes.

Just tried it this evening and nothing. Same error about GRUB being over the maximum number of cylinders on the HDD. What exactly is the MBR? Is it a special spot with space set aside?

I’m thinking when I run the grub-install it must be doing something to the MBR because the windows boot loader is no longer there. I get the error instead of windows starting right up. But something must also be going on elsewhere on the HDD if the error is about being above a max cylinder.

MBR is the first sector of the disk, which also contains the partition table. Also the first track of the disk is reserved for bootloaders. This initial GRUB code loads the stage2 bootloader and after that the kernel and initrd in the /boot directory.

Anything loaded by GRUB has to be reachable by the BIOS because that’s all that GRUB has to do disk I/O. On older BIOSes, there is a 128GiB limit due to the size of the arguments to the BIOS I/O calls. It looks like your boot files are beyond this limit. That is why some machines require a /boot partition on the lower cylinders of the disk.

To fix this you need to put the boot files below the 128GiB mark. You may be able to use a gparted rescue to shrink / enough to insert a /boot partition before it and copy the boot files there.

Oh there’s one more thing worth checking. If the BIOS offers you the choice of native SATA handling or IDE emulation, try the former.

Okay, so the bootloader in the MBR is, in effect, calling to the installation location of GRUB (/boot) and because I have that located on sda5, which is above the 1024 limit, it won’t work. So the EISA partition is causing problems. I need to move it out of the way and setup a /boot partition at the beginning of the disk and then install GRUB to that location. I think I have a copy of gparted lying around somewhere, so I’ll try to find it and give this a try. I’ll fill you in on the results.

Not so fast, there are a few odd things about your situation.

The 1024 cylinder (500MB) limit is really old, it is only found on BIOSes older than 15 years or so.

The 128GiB limit is about 10 years old.

Looking at your partition sizes the puzzling thing is that your first Linux partition should be under the 128GiB limit. Also it did manage to load the kernel when the boot sector was on sdb.

So something fishy is going on.

Do you get an interactive GRUB prompt? If so what happens if you do this:

root (hd0,4)
kernel /boot/vm

At this point you can try to do file completion with TAB and see if you get the BIOS limit message.

You can also try to start GRUB from a rescue disk and see if you can interactively load the kernel.

Also did stage 1.5 get loaded, it should say what stages it is loading. And do you still get the reference to (hd1,4)/boot/message?

Another thing is your menu.lst might be wrong. When you had the IDE disk in place, the SATA disk would pushed back to hd1. Now that you have removed the IDE disk, the SATA disk is back at hd0. So all references to hd1 in menu.lst would have to edited to hd0. That would explain the (hd1,4)/boot/message not found.

I’ll have to try your suggestions on monday when i’m back in my office. I believe it does load stage 1.5 and then I get the (hd1,4)/boot/message error.

When I used the grub-install… command with liveCD, shouldn’t that have created a new /boot/menu.lst that references hd0 instead of hd1 automatically?

No, grub-install doesn’t touch menu.lst. There would be howls of protest if it did since it contains all the info about what OSes are available. In fact menu.lst can be edited at will any time, that’s the advantage of GRUB over LILO.

To be really sure of what GRUB is installing, do the steps by hand from the rescue system, after editing menu.lst:

grub

grub> device (hd0) /dev/sda
grub> root (hd0,4)
grub> setup (hd0)

At this point you will get messages about embedding various parts of GRUB on the disk.

Bravo, man, that did the trick. I simply opened up menu.lst with vi and changed all the hd1’s to hd0’s (and two hd0’s to hd1’s). Shutdown, pulled the IDE hardrive, started it up and GRUB popped right up. No need to reinstall or use the rescue system. Thanks a lot for the clever solution.