-   Linux - Software (
-   -   Typo with GRUB caused Win98 to be unbootable (

wapcaplet 11-27-2003 06:41 PM

Typo with GRUB caused Win98 to be unbootable
Kay, so I got Win98 installed on /dev/hda, and then installed Gentoo on /dev/hdb. Everything worked fine, and Windows was bootable after following the great instructions provided on Gentoo's site. I had to do some kernel reconfiguration, so afterwards, I ran GRUB and did this:

> root (hd1,0) // /boot partition of Gentoo
> setup (hd0,0) // first partition on hda! not MBR. oops!
> quit

One small typo in the second line is what messed it up, I think; rather than installing the bootloader into the MBR of the first disk, it installed into the first partition of the first disk. I should have typed:

> setup (hd0)

So now GRUB is installed both in the MBR (hd0) and in the first partition (hd0,0). Now, when I select "Windows" from the boot menu, it tries to boot from the boot record on (hd0,0)... which is just GRUB again, giving me the bootloader menu.

As I understand it, there's no way to remove a bootloader from a disk... is there any way, outside of reinstalling Windows (ugh) to restore the Windows boot record on (hd0,0)?

Tinkster 11-27-2003 07:42 PM

Sorry to say that, but not too likely. Hope
someone else here has better news, and
a fair idea of what those so and so many
bytes are MEANT to look like instead of


wapcaplet 11-27-2003 08:55 PM

Dang. I hope someone else has some suggestions :)

At least Gentoo is working great; I shouldn't have any problems mounting the partition in question and backing up anything important before reinstalling. Should also be easy to restore the MBR using the Live CD after Windows obliterates it...

I am liking Gentoo so far, aside from the lengthy merging/compiling process. Getting distcc installed right now to speed that up, though!

DurantDL 11-27-2003 10:07 PM

Basically you overwrote the DOS boot sector with grub.
Indeed, there are various ways to fix this.

The original DOS boot sector backup should be in /boot.
You can put it back in place using the "dd" command.
For IDE windoze drive C: try something like this:
% dd i=/boot/boot.dos o=/dev/hda1 bs=512 cnt=1

If you have a bootable DOS disk, you could try using "recover".

wapcaplet 11-27-2003 10:27 PM

Thanks! Both of those options sound considerably less painful than reinstalling Windows :)

My /boot directory has only Linux kernel stuff in it, but /boot/grub has the following:


-rw-r--r--    1 root    root        7872 Nov 26 02:37 e2fs_stage1_5
-rw-r--r--    1 root    root        7536 Nov 26 02:37 fat_stage1_5
-rw-r--r--    1 root    root        6912 Nov 26 02:37 ffs_stage1_5
-rw-r--r--    1 root    root          184 Nov 27 10:27 grub.conf
-rw-r--r--    1 root    root        1256 Nov 26 02:36 grub.conf.sample
-rw-r--r--    1 root    root        8480 Nov 26 02:37 jfs_stage1_5
-rw-r--r--    1 root    root        7072 Nov 26 02:37 minix_stage1_5
-rw-r--r--    1 root    root        9440 Nov 26 02:37 reiserfs_stage1_5
-rw-r--r--    1 root    root        33856 Nov 26 02:36 splash.xpm.gz
-rw-r--r--    1 root    root          512 Nov 26 02:37 stage1
-rw-r--r--    1 root    root      106428 Nov 26 02:37 stage2
-rw-r--r--    1 root    root        6528 Nov 26 02:37 vstafs_stage1_5
-rw-r--r--    1 root    root        9384 Nov 26 02:37 xfs_stage1_5

Any idea which of those would help me? Only 'stage1' is 512 bytes, but I'm assuming that's the GRUB loader that's supposed to go in the MBR. Maybe 'fat_stage1_5'?

Don't think I have a DOS boot disk lying around (and this machine has no floppy drive anyway), so maybe the Win98 CD-Rom can do 'recover'.

Or, if someone else has a boot.dos that they could email me, that would be wonderful! Presumably they're all about the same...?

DurantDL 11-28-2003 12:08 AM

Hmm .. where did I get that boot.dos from?
Perhaps left over when I upgraded from lilo?

I am afraid my C: boot.dos has bad values for your HDD.
I recall the boot sectors are customized for each partition;
I once moved the MBR to floppy to boot directly from C: ...

DOS drive partitions have a boot record, two FATs, and root directory.
Sizes vary according to partition size and format (FAT-12, -16, or -32).
DOS will also refuse to repair partitions it does not recognize.

I propose the following solution, if you are williing:
- use the Linux CD to backup the "grub" MBR
- backup the C: partition header
- erase the (grub) boot sector
- run the WinCD "recover" command
- check to see if all is well with C:
- if not, save off the new boot sector
- use "dd" to replace the first Mb of C:
- use "dd" to restore the new boot sector
- use the Linux CD to restore the "grub" MBR
Sound like a good strategy to you?

Since other solutions involve using various repair toolkits,
you should use "dd" to back up the HDD partition header.
Maximum size: boot=512, FATs=2*65536*4, root=[dir_entries]*32
You should be safe if you back up the first Megabyte.

- use the Linux CD to backup the "grub" MBR

- backup the C: partition header
% dd if=/dev/hda1 of=/root/hda1.header bs=1024 cnt=1024

- erase the (grub) boot sector
% dd if=/dev/zero of=/dev/hda1 bs=512 cnt=1

- run the WinCD "recover" command
Boot the WinCD, and exit to the prompt
> recover C:
- check to see if all is well with C:

- if not, save off the new boot sector
% dd if=/dev/hda1 of=/boot/hda1.boot bs=512 cnt=1

- use "dd" to replace the first Mb of C:
% dd if=/root/hda1.header of=/dev/hda1 bs=1024 cnt=1024

- use "dd" to restore the new boot sector
% dd if=/boot/hda1.boot of=/dev/hda1 bs=512 cnt=1

You really only needed the boot sector, but WinCD may clobber more.

- use the Linux CD to restore the "grub" MBR

wapcaplet 11-28-2003 07:45 AM


Okay, I was unable to find a 'recover' executable on the Win98 boot CD (or in my \windows\command directory). There was a 'recover.txt' which described how to recover from a previous backup, but I have no such backup.

Anyhow, after a bit more searching, it turns out that I'm not the first person to have done this. This person and this person did the same thing, and the recommended restoration process was to run "sys c:" from a boot floppy. The Win98 CDrom doesn't come with 'sys', so I just used the CD to boot. Can't run 'sys' on the current drive, so I did:

System transferred
1 file(s) copied
E:\> sys c:
System transferred

(I can't believe I ever thought that DOS was cool. What a wussy interface it is compared with *nix). Anyway, windows will now boot. It has apparently lost a bunch of driver settings and whatnot, and the video mode is wrong, but that can be easily fixed.

Thanks a bunch for your help, at any rate! The solution turned out to be much easier than I'd have expected.

wapcaplet 11-28-2003 08:21 AM

Blah. That did not work, apparently. Win98 booted, but practically nothing worked; all my devices were gone, no CD-Rom drive, and I got a protection error on booting it the second time. I tried restoring the original first megabyte that I backed up per your suggestion, and then overwriting the first 512 bytes with the post-recovery version; it booted and seemed okay, but I got critical errors with just about everything I did.

Rather than putz about with it any longer and probably end up with a flaky (flakier) Windows install, I am just gonna reinstall Windows :) Already got the important stuff backed up (which wasn't too much, since this box just had a fresh install a couple weeks ago), so it should be fairly painless. And actually, we're about to buy a new 80GB hard drive, so maybe I'll just start over with that; the drive that's in there is quite old, and could well be the source of some of the problems.

All times are GMT -5. The time now is 04:26 AM.