Booting Linux from Windows' Boot Manager
By Thiravudh Khoman
Some people aren't aware of this, but it's possible to use Windows NT/2000's boot manager to boot into Linux (besides booting Windows of course). In a nutshell, what you need to do is to: a) save the first 512 bytes of the Linux boot partition to a file, b) copy that file to C:\, and then c) add a line to C:\BOOT.INI that points to that file.
There are several reasons why you might want to do this: a) you may be more comfortable with Windows' boot manager, b) if you decide to remove Linux from your system one day, you'll still have the Windows boot manager around, rather than being left with LILO or GRUB, c) you can boot into a Linux installation that's located above 1024 cylinders without using a boot diskette (granted, many Linux boot managers can do this now too.)
Before we proceed, let's make a few assumptions:
You're using a single hard disk that already has Windows 2000 Professional and/or Windows 2000 Server (or Windows NT for that matter) installed on it. Presumably, this should work on a system with two or more hard disks as well.
You have sufficient free space on the hard disk on which to install Linux. If not, you'll need to do some re-partitioning or add another hard disk.
You're going to install Red Hat Linux v8.0 (hereafter, "RH8"). Actually, this procedure should work with most any Linux distribution, although the sections I'm flagging will probably be located or labeled differently.
You have 2 diskettes ready. The first one will be overwritten completely to create a Linux boot diskette, so make sure nothing is needed on it. The second one should be DOS formatted and need not be empty since we will only need enough space to save a 512 byte file.
Step by Step
Here are the exact steps:
Back up your data if you care to do so (i.e. don't blame me if this doesn't work or screws things up).
Place the first RH8 CD into your CD-ROM drive and boot your computer from it.
Run through the RH8 installation process as per your book or instructor until you come to the screen that's titled: "Boot Loader Configuration" (figure 1 - This is a sample screen only!).
On this screen, check the "Configure advanced boot loader options" box and then click "Next".
On the next screen ("Advanced Boot Loader Configuration") (figure 2 - This is a sample screen only!), under the "Install Boot Loader Record on" section, make the sure the radio button next to "/dev/hda# First sector of boot partition" is selected. On my computer, hda# is hda5. On your system, it may be different. Write down this hda number because you will need it later!
WARNING: It is critical that you DO NOT install the Linux boot loader into the Master Boot Record (MBR) as this will overwrite the Windows boot manager! Be VERY, VERY careful here!
Click "Next" and continue with the installation process until you come to the "Boot Disk Creation" screen (figure 3).
Make sure the radio button next to "Yes, I would like to create a boot disk" is selected (it is, by default) and then click "Next".
Proceed with the boot disk creation and remove it when it is finished.
Continue with the installation process as instructed. Before re-booting at the end of the installation, remove the second RH8 CD and insert the Linux boot diskette you created. You will next boot Linux with this diskette.
The first time RH8 loads, you will be prompted to perform a few additional post-installation tasks. Do or don't do these as you wish.
When you finally reach the Linux login screen, login as root.
Open up a terminal window (System Tools -> Terminal).
You will now need the hda number you wrote down. Assuming that the boot partition is at hda5, type:
dd if=/dev/hda5 of=boot.lnx bs=512 count=1
If hda5 is NOT your boot partition, change it as appropriate. If you FORGOT what your hda number was, from the terminal window, type: df, then determine which hda# is associated with the /boot partition.
A file named "boot.lnx" should now have been created in root's home directory. Do an "ls -l boot.lnx" to confirm this.
Insert a DOS formatted floppy diskette into the floppy drive and while still in the terminal window, type:
mcopy boot.lnx a:
This uses MTOOL's "mcopy" command to copy a file from a Linux partition to a DOS formatted diskette.
Remove the DOS diskette.
While still in the terminal window, type:
shutdown -r now
This will reboot your computer.
With no CD in the CD drive or floppy in the floppy drive, your computer should still boot into Windows. If you have more than one copy of Windows installed, the Windows boot manager selection screen should appear. It really doesn't matter which Windows you boot into, but it makes sense to boot into the fastest loading Windows.
Make sure you log into Windows as administrator or as an adminstrator-equivalent. Once you're inside Windows, go to the command prompt (Start -> Accessories -> Command Prompt). If you're not already there, change to the root of the C: drive.
Insert the DOS floppy diskette that contains the boot.lnx file into the floppy drive and then copy it to C:\ using the DOS copy command or Windows Explorer.
Next, we need to edit the BOOT.INI file so that it knows about boot.lnx. BOOT.INI should be a system file and hidden from view. When you type:
the attributes of BOOT.INI should be A (archive), S (system), and H (hidden).
In order to edit BOOT.INI, you will need to change its attributes first. Type:
attrib -s -h boot.ini
Now that BOOT.INI has been unprotected, you can either edit it from DOS with EDIT.COM or from Windows with NOTEPAD. If you choose the latter, leave the command prompt window open for the time being since you will need to change BOOT.INI's attributes back to SH later.
Inside the editor of your choice, add a line to the end of the file that contains the following:
c:\boot.lnx="Red Hat Linux v8.0"
The text between the double quotes are comments and you can change it as you see fit.
Depending on how many copies of Windows you have installed, your BOOT.INI may now look SOMETHING like this:
multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows 2000 Professional" /fastdetect
c:\boot.lnx="Red Hat Linux v8.0"
Save the changes you made to BOOT.INI and then return to the command prompt and type:
attrib +s +h boot.ini
If you wish to change the order of the selections in the boot manager screen (e.g. to make Linux appear before Windows), just change the order of the relevant lines in BOOT.INI. Likewise, if you wish Linux to be the default selection, change the text after the "default=" line to:
Reboot your computer and the Windows boot manager should now provide the added option to boot into Linux. Select "Linux" and notice that you will be taken to the Linux boot manager (probably GRUB) screen first. Finally, within GRUB, select "Red Hat Linux (2.4.xx-xx)" and Linux will start its regular boot process. (Interesting trivia: Selecting "DOS" will take you back to Windows' boot manager screen).
At this point in time, you will no longer need either of the floppy diskettes. But as with all boot/rescue diskettes, it might be wise to save the Linux boot disk if you can spare it.
I learned about this technique from an excellent book by Mike McCune titled "Integrating Linux and Windows" (Open Source Technology Series, Prentice Hall PTR, 2001, 392 pp, List Price: $39.99).
If you plan to straddle both the Windows and the Linux worlds, I'd highly recommend this book. Although it's not exactly a book for beginners, it illustrates how a variety of tasks can be performed under both Windows and Linux, and how the two may be made to co-exist. It's about two years old though, and could certainly do with a wee update.