Jump to content

Win9x (or Dos) installing Grub2 bootloader


awkduck

Recommended Posts

First off, this is not a post about writing a grub.cfg file, or booting Win9x using Grub2. I don't mind if it turns into that. But "initially" this is just about installing grub, from Win9x. And it is only in regards to BIOS booting systems.

Grub2 has installation files, for Windows. They will run under win9x, but only seem to accept NT physical drive designations. That can make installing it a little rough. Maybe there is some option included, that provides the needed functionality. But it wasn't in the user manual, nor did anything turn up online.

There are many bootloaders and Grub2 forks out there. It might be possible to use one of those, quite easily, using only Win9x. I use Grub2/Grub4Dos/Syslinux, individually and in combination, all the time. There are just times, when Grub2 works well for me. So don't read this as a "You should use Grub2" post. It isn't always the most flexible bootloader, when you are working with Win9x.

If you are familiar with Linux, or you have a Window NT variant, you probably don't need this information. This is for the real masochists out their, that want to do everything within their Win9x domain.

Also, if you haven't messed with a hex editor, or your systems is to important to risk its functionality, you probably shouldn't mess with this.

Disclosure: There may be a different, and perhaps official, way of doing this. I just gave up looking. Turns out, installing it "this way" is easier then writing the grub.cfg file by hand; which you would also need to do.

First you need to download Grub2 for Windows. Then you need a handy "Disk Viewing" hex editor (maybe). I used the HxD hex editor.

There are Two ways you can go about this.

-If you already have a bootloader, you might just want to chainload Grub2. This would not require a hex editor; so you can leave manually editing you harddrive alone.

-If Grub2 will be your main bootloader, then you will need to chisel and hammer some.

No matter which way you go, you need the Grub core.img file. So lets build one.

Once you have your Grub download unzipped, you'll see a bunch of "EXE" files. You can get rid of all but maybe one or two. For certain you need "grub-mkimage.exe". But if you already have a "syslinux.cfg" file, you can play with "grub-syslinux2cfg.exe". I won't be doing anything with that, here.

There are also a couple of folders you can get rid of. Both "i386-efi" and "x86_64-efi" are not needed.

Now, in this same folder, you want to run this command:

grub-mkimage.exe --output=./core.img --format=i386-pc --prefix=(hd0,msdos1)/boot/grub biosdisk part_msdos fat

Note: This command can also be ran in real Dos, but you need "long file name" support and "HxDos" extender loaded.

Now "(hd0,msdos1)/boot/grub" represents the location of the folder you just ran that command in. So you will want to rename it "grub", and then create a folder "C:\boot" to move it to. But you will have to adjust things, if you want to have this folder somewhere other then "C:". If it is on a USB drive, (hd0,msdos1) is still fine. When booting from it, BIOS sees it as the first disk. If you are chainloading, then just use "/boot/grub".

So in hdx, x equals the physical disk the grub folder is on. In msdosx, x equals the partition it is on.

If you want to have it on a partition that isn't "Fat16/32", then you would want to change out "fat" for the correct partition type. For example ntfs, ext2, exfat, jfs, etc. "Ext2" also handles "Ext3". These names correspond to modules in the "/boot/grub/i386-pc" folder. So if there isn't a .mod file for the partition type you need, then it isn't supported. You don't need support for all of these partition types, in core.img. You just need the one for the partition that "/boot/grub" is on. Once Grub boots, and locates that folder, it can access the other mod files.

Now, if you want to chainload Grub, then you need one more thing added to "core.img".

Inside the Grub folder, you would run:

copy /b i386-pc\lnxboot.img + core.img boot.img

If you are chainloading, you could delete core.img and/or rename boot.img to core.img. It doesn't really matter what it is called.

That is pretty much it, for the chainloaders. Just create your grub.cfg file, in "/boot/grub", and point your other bootloader at "boot.img".

But you real masochists, keep on.

If you are going to format the entire drive, you can copy the whole Grub "MBR" over before hand. But if you already have "needed" information/partitions on the disk, then you'll need to take more care. And you can throw in the towel right now, if don't have 28KBs free, after then end of your first sector. A standard MsDos MBR should be fine. Modern Linux made partition have even more space in there.

Okay, so now you will need to start your hex editor, and open your target disk. Then open the file "\boot\grub\i386-pc\boot.img". Like I mentioned earlier, if you plan to format the entire drive, just copy the entire contents of "boot.img" and paste it on your drive; starting at 0x0. But if you already have data/partitions you want to preserve, then you may want to copy the whole fist sector of you disk; and save it somewhere other than this disk. Then you will only want to copy "boot.img" from 0x0 to the end of 01A3 (01A0x3). Now paste that to your drive at 0x0.

Note: If things don't work out, you can copy/paste over your "saved" original first sector.

Finally, if you have enough room for it, you can open/copy the entire "core.img", and paste it at the very beginning of your drives second sector.

That should be it. Now with a good grub.cfg file in "\boot\grub" you should be all set.

If you are unsure about any of this, maybe try it on an empty "USB" pendrive.

Edited by awkduck
Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...