Monday, November 07, 2005

Such simple things. . .(pt. 1)

This was a lazy weekend, with nothing to do other than mooch around at home. So Lou got on with getting FreeBSD doing what she wanted, and so I wound up spending a while on my PC as well.

There were a few minor niggles that had been bugging me for a few weeks. Nothing major, just tiny little things that could easily be ignored. While I was on my computer anyway, I thought, I'd fix these slight issues. Should be easy enough, right?

The two issues were partially related: I couldn't get a new version of the kernel to boot, because it said I was passing an invalid root option; and I couldn't make any changes to my Grub configuration, which is where the root option is specified.

So, start with Grub. Grub was fouled up in a complex way. A while ago, I installed a SATA disk to replace my IDE HD. SATA is faster, you see. That left me with a new, unused hard drive, so I figured I'd install BSD on it for a play around.

Somewhere in the madness of adding disks & OSes, Grub got fouled up. And fouled up badly: It wouldn't give me a command prompt, it wouldn't let me repair it from a rescue CD, it just sat and error-messaged me. In the end, I wound up installing a new Linux from an install disk I had lurking, just so it would install a working Grub.

Having had such a nightmare, I determined to make sure it never happened again. I copied all my /boot files over from the SATA disk to the IDE, and installed Grub to the IDE MBR. This way, if my SATA Grub got fouled up, I'd still be able to use the IDE Grub, and vice-versa.

The problem was, when I tried to edit Grub's config on SATA, none of the changes worked. I had a suspicion that the IDE Grub was actually the one booting, instead of the SATA one. So I rebooted, went into the BIOS, and sure enough, it was set to boot HDD0 - the IDE disk.

Now, I wasn't sure if the SATA disk qualified as HDD2 or SCSI1, so I tried all the options one after another. HDD1 gave me FreeBSD's boot loader, so it was obviously my second IDE drive. HDD2 gave me HDD0's bootup. SCSI gave me a grub command prompt, but no menu.

Odd. I checked the grub config, and it was fine. But then I found that, although Grub referred to the SATA disk as hd2 from Linux or when booting from HDD0, it thought it was hd0 when booted off SATA. Obviously it was confused about disk numbers, and hence wouldn't load a config file.

So I copied SATA /boot to IDE /boot, set IDE /boot to mount in /etc/fstab, and rebooted off IDE. Grub no longer gave me a menu, just a command prompt.

Nghhhhh...

A bit more experimenting only made things worse: Mounting the IDE /boot in Grub and telling it to load the config file worked perfectly. The config file therefore MUST be valid. Why wouldn't it load it automatically??

Eventually, I found the problem. It was caused by Grub trying to be clever about /boot

You see, if you have /boot as just a directory in your root partition, then when mounted, grub's files live in /boot/grub. But if you have a /boot partition, then mounting the /boot partition will put grub's files in just /grub

This means that, any time you run setup from Grub, it looks for both /boot/grub and /grub. This guarantees an error message for one or the other, and nobody likes to see errors. I got around this by symlinking /boot/grub to /boot/boot/grub, so it would find its files in both locations.

But at some point, it seems to have over-written the symlinked /boot/boot with an actual directory. And /boot/boot/grub didn't have my grub.conf file - hence its refusal to load the config by itself.

I wiped /boot/boot, and rebooted. Grub menu popped up. Hurrah! I have a working Grub at last.

Time to fix the other problem: Can't boot a new kernel. I decided this would occur after a short break. . .

2 Comments:

Computer Guru said...

The easiest way to reinstall the MBR without losing data: Fixing a Broken MBR: the data-loss free way.

2:45 PM  
Dominic said...

Actually, I probably should have mentioned that, following the whole situation, I found how to burn Grub onto a CD.

Now I can rest secure in the knoweldge that I can always get a working Grub command prompt, no matter what I do to my hard drives.

4:41 PM  

Post a Comment

<< Home