DIRECT BOOT INTO WinNT/Win95/DOS/Linux from the NT Boot Loader

This document written by Sean Edmison <sedmison@owlnet.rice.edu>

Note: This howto is largely based upon an earlier howto by J. David Bryan; I have added information on Linux and changed the organization somewhat, but have left his text more or less intact wherever it still applies. Also, thanks to Arthur D. Jerijian (jerijian@seas.ucla.edu) for additional information about the Unix dd command. See the References section for pointers to these sources and applicable Microsoft Knowledge Base articles, as well as a reference for doing all this with FreeBSD.


It is possible to boot directly into each of these operating systems using the Windows NT 3.51 boot loader (note that this procedure will not work with NT versions prior to 3.51, and I have not tested it with version 4 yet). Specifically, one can boot directly into DOS, without going through Win95, from the NT multiboot menu. In fact, I have no doubt that OS/2 and other operating systems can be added to this procedure given an understanding of the way the particular boot sequence works for the operating system. The two required conditions for bootup are:

  1. The correct system files must be present with the required names.
  2. The correct boot sector must be executed.

The information contained herein is derived in part from the Microsoft 95WRK.HLP file supplied on the Win95 final beta CD, modified for post-installation operation (the relevant page is titled, "Installing Windows 95 for Dual Booting with Windows NT").


MY SYSTEM

I have Windows NT 3.51 Workstation, Windows 95, DOS 6.22 (with WFW 3.11, though this does not matter), and Slackware Linux 1.2.13. I installed DOS first, then Windows 95, then NT, and then Linux, though I'll attempt to explain how to "insert" another operating system so that you can do this in an arbitrary order. What is central here is the NT boot loader: This won't work without Windows NT 3.51 and its boot loader.

My primary (bootable) partition is the first partition of the first hard drive (this is drive C:) which is FAT. I have each system on a separate partition, though this is not necessary -- it is just easier for me to remember what's what and easier to backup and restore files in emergencies.

Drive C: therefore contains all of the startup files for all operating systems. A listing of all files (including hidden files) should contain at least the following NT system startup files:

If you have Windows 95 installed, then you should also have the following files if DOS was booted more recently than Win95:

or the following files if Win95 was booted more recently than DOS:

If you have not installed Windows 95 yet, then you should just have the following DOS files:

Finally, I have a Linux bootsector file that points to the volume on which I have installed Linux (with LILO):

(I'll explain how to create this little gem in the text to follow.)


THE END RESULT

When you are done, and you reboot, you will get the NT boot loader menu (that starts out at the top of the screen with "OS Loader V3.51") with (at least) these choices:

and when you select a choice, you will then see one of the following messages on the screen (depending on which system you select):


BEFORE YOU START

  1. Make backups of the files BOOT.INI and BOOTSECT.DOS in the root of C: (BOOT.INI is hidden; BOOTSECT.DOS may be) if you already have NT installed.
  2. It's not a bad idea to have a backup of your Linux lilo.conf file (usually /etc/lilo.conf) if you already have Linux installed.
  3. Be sure you have BOOTABLE Windows NT Setup Diskettes (three diskettes). If not, run "winnt32 /o" from the installation CD to make them.
  4. If you intend to install DOS, be sure you have a BOOTABLE DOS diskette that contains the SYS.COM program. You can also use this system to fix any problems you may introduce in error (you can restore BOOT.INI and BOOTSECT.DOS and start over).
  5. If you intend to install Windows 95, be sure you have the Windows 95 installation disks or CD-ROM handy.
  6. If you intend to install Linux, be sure you have your Linux boot/root disk(s) handy.
  7. If you have not installed Windows 95 before but intend to, be sure that you can boot into DOS and Windows NT correctly before you do so.
  8. If you have installed Windows 95, be sure you can boot into NT, Win95, and DOS (via Win95). If you can't reach DOS from Win95, you may need to add the line "BootMulti=1" to the "[Options]" section of MSDOS.SYS (do this from within Win95, to be sure you edit the right file).
  9. If you have installed Linux, be sure you can start Linux (with LILO or via boot/root disks). Typically the only way to set this up initially is to have LILO write its boot information into that master boot record. (This means that it will come up BEFORE NT's boot loader. This is okay, because the procedure herein will unify things.)
  10. It will help (but is not necessary) to have a hex dump program available (or you can use the NT DEBUG command) so you can look at the contents of the BOOTSECT files and verify their correctness.

WHAT YOU NEED TO DO

The steps needed to implement directly booting to an arbirary OS are:

  1. Make available separate Win95, DOS, and Linux boot sector files.
  2. Edit BOOT.INI to add separate choices for Win95, DOS, Linux, and and other operating systems you use.


CREATING THE DOS BOOT SECTOR FILE

What NT's boot loader uses to load any given operating system is a tiny bootstrap file that points it at the rest of the operating system's boot code. These files are pretty easy to create and maintain, given the right tools (and a fair amount of patience). For creating boot sector files, there are a couple of methods.



...on a machine with Windows 95 and Windows NT
If you already have Windows 95 and Windows NT working, then the BOOTSECT.DOS file in the bootup directory (the root directory of the C: drive usually) is the WINDOWS 95 BOOT SECTOR FILE. (This is not the same as the DOS boot sector file.) If you have this file, back it up as BOOTSECT.W40 or BOOTSECT.W95 or some other name that you will remember as being the Windows 95 boot sector.

Now, in order to add DOS to the mix, you need a BOOTSECT.DOS that contains a DOS boot sector. The good news is that NT will make one for you. The bad news is that you have to go a fair way through the setup program for it to generate the BOOTSECT.DOS (which takes about 1 second). To do this, use your NT installation and setup disks/CD-ROM to Repair your NT boot files.

This file, BOOTSECT.DOS, is your DOS boot sector file. SAVE THIS FILE! You will want to copy the actual DOS BOOTSECT.DOS file because Windows NT will OVERWRITE the boot sector file if you reinstall it, because BOOTSECT.DOS is the default filename. So you can just copy this file to BOOTSECT.622 or some other name that you'll remember as being the actual DOS bootsector file.



...on a machine with DOS and NT but without Win95
Alternately, if you're setting up a machine from scratch or you just haven't installed Win95 yet, and if you installed NT over DOS, then the BOOTSECT.DOS file in the bootup directory IS the DOS boot sector file.

SAVE THIS FILE! You will want to copy the actual DOS BOOTSECT.DOS file to a new file with a different name because Windows NT will OVERWRITE this boot sector file if you install or reinstall it, as BOOTSECT.DOS is the default filename. So you can just copy this file to BOOTSECT.622 or some other name that you'll remember as being the DOS bootsector file.




CREATING THE WINDOWS 95 BOOT SECTOR FILE

If you don't yet have a Windows 95 boot sector file (by backing one up in the process above), then there are a couple of ways to create one. First, if you have DOS and Windows NT installed, but have not installed Windows 95 yet, back up your DOS bootsector file (as described above) and run Windows 95 setup from DOS. Once this process completes, you'll probably need to repair your NT installation. When Windows NT setup finishes fixing your bootup files, copy the resulting BOOTSECT.DOS file to BOOTSECT.W40 or BOOTSECT.W95 or some other filename that you'll remember as being the Windows 95 bootsector file.

If you already have Windows 95 and Windows NT installed and you want to make a bootsector file specifically for Windows 95, then you can use Windows 95 sys.com to rewrite Windows 95's system files onto the Master Boot Record. Then you will need to install or reinstall Windows NT, and once it finishes installing, the resulting BOOTSECT.DOS file will be the Windows 95 bootsector file. Save it to BOOTSECT.W40 or BOOTSECT.W95 or some other filename that you will remember as being the Windows 95 boot sector.





CREATING THE LINUX BOOT SECTOR FILE

So far so good? If you've installed DOS, Windows 95, and Windows NT, then right about now your machine should load DOS (directly if you've installed the DOS bootsector file into your BOOT.INI file, or indirectly through Windows 95 otherwise), Windows 95, and Windows NT. (And, if somehow all of this didn't kill off LILO, then it will probably run LILO, and then run the NT loader. This is okay, too, for now.)

If all of this has totally wiped LILO from the picture at bootup, don't panic. Just boot Linux from your boot/root floppies with the boot option mount root=/dev/hd? (where /dev/hd? is the volume of your Linux installation--that is, the first partition of the first IDE volume would be /dev/hda1, or the third partition of the second SCSI volume would be /dev/sdb2, etc.). This should get you back into Linux with minimal hassle (all of Linux should still be there--it's just that LILO temporarily isn't around to boot it up!).

Once DOS, Win95, and NT boot okay, it's time to add Linux to the NT boot loader and to remove LILO from the Master Boot Record. The major trick here is to install Linux's boot information onto the superblock of the volume on which Linux resides (usually LILO wants to write its information to the master boot record, and this won't work for our purposes).

Now, assuming that your LILO installation currently expects to be in the master boot record, this needs to be changed. The pertinent LILO information is in the lilo.conf file (again, usually in the /etc directory). So with your favorite editor, edit your lilo.conf file as follows: Replace the boot=/dev/hd? line that is currently there (probably boot=/dev/hda) with a line referring to the superblock of the Linux volume (again, this would be /dev/hdb1 for the first partition of the second IDE volume, or /dev/sdb2 for the second partition of the second SCSI volume, etc.). At this point, since we're expecting LILO just to have to boot Linux, you might also want to comment out whatever menu options are for booting DOS (unless you work for the Department of Redundancy Department and want to have multiple ways to boot DOS and yet another choice at bootup!) Once you have made the appropriate changes, save the file and rerun lilo to update the boot information. Then remove LILO from the MBR This should fix LILO to behave properly when next we launch it.


...with BOOTPART

Once Linux is correctly installed (but not, at this point, bootable anymore), it's time to create the file that NT's boot loader will use to start up LILO. For this purpose, I recommend the shareware utility BOOTPART, which is designed exactly for this purpose. Running BOOTPART with no parameters should display all partitions on the machine and what file system they are formatted with. Then running BOOTPART with a partition number and a boot sector filename should create a new boot sector file (and possibly add it to your BOOT.INI file, but that's jumping ahead a bit). For this process, follow the instructions for BOOTPART, as the exact incantation may change somewhat from time to time and version to version. And when you do create the file, I personally recommend the filename BOOTSECT.LNX, but again, use whatever filename you will remember as being the boot sector for Linux.

For more information on BOOTPART, take a look at the web site:

http://ourworld.compuserve.com/homepages/gvollant/bootpart.htm


...with dd

Alternately, if you want to make the BOOTSECT.LNX file from within Linux, you can do it with the dd command:

dd if=/dev/hda? of=/mnt/c-drive/bootsect.lnx bs=512 count=1

where hda? is your boot partition in Linux and /mnt/c-drive is where your C:\ drive is mounted. Then, you can arrange LILO to write the bootsector to this file by setting the boot= parameter in /etc/lilo.conf:

boot = /mnt/c-drive/bootsect.lnx



Removing LILO from the Master Boot Record

The only complication to all of this is removing LILO from the Master Boot Record (MBR). To do this, you have to rewrite the MBR with the command:

fdisk /mbr

from Windows 95 or DOS. THIS WILL WIPE OUT THE MASTER BOOT RECORD, so you will have to use your NT installation disks/CD to repair NT's master boot record files!


ADDING DOS TO THE BOOT.INI FILE

Once you have all these boot sector files floating around, it's time to plug them into the NT loader. (Note: The following procedure can be used from any of the available systems; I used DOS. Be aware, though, that until NT is set up, there is no BOOT.INI file, so you need to have set up Windows NT by this point.) Also, the addition of items to the BOOT.INI file can be done in whatever order you want, but of course if a menu selection refers to a not-yet-created or invalid boot sector file, then your results will be less than favorable (probably a nasty message--I've never really had the urge to try this....)

To get the correct system files (with the correct names), edit the BOOT.INI file (hidden and read-only) present in the bootup directory (probably the root of C:). You should have lines something like the following:

  [boot loader]
  timeout=10
  default=multi(0)disk(0)rdisk(1)partition(1)\WINNT

  [operating systems]
  multi(0)disk(0)rdisk(1)partition(1)\WINNT="Windows NT Version 3.51"
  c:\bootsect.dos="Windows 95"

Edit the "c:\bootsect.dos" line and add a new line following it, as follows:

  BEFORE EDITING                  AFTER EDITING
  ----------------------------    --------------------------------------
  c:\bootsect.dos="Windows 95"    c:\bootsect.w40="Windows 95" /WIN95
  (new line)                      c:\bootsect.622="MS-DOS 6.22" /WIN95DOS

The /WIN95 and /WIN95DOS switches cause NTLDR to rename the DOS and Win95 system files back and forth so that the correct names are used with the operating system selected. (If you have not noticed before, look at the hidden files in the root of C: when running DOS and Win95. Under Win95, the DOS files are renamed IO.DOS and MSDOS.DOS; under DOS, the Win95 files are renamed WINBOOT.SYS and MSDOS.W40; IO.SYS and MSDOS.SYS belong to the "current" operating system).

Note that the /WIN95 and /WIN95DOS switches are only recognized by NTLDR version 3.51. The NTLDR from versions 3.5 and earlier won't recognize these switches, so the renaming won't take place.

You have also requested that Windows 95 be booted using the boot sector in the file BOOTSECT.W40, while DOS is booted using BOOTSECT.DOS, which is what all of this furious creation of boot sectors was about.


ADDING LINUX TO THE BOOT.INI FILE

Again, be aware that there is no BOOT.INI file until after you install NT, so make sure that NT is running before you attempt this section.

Adding the Linux boot sector file (BOOTSECT.LNX or whatever name you created it with using BOOTPART) should be trivial. In fact, BOOTPART has an option that will add the Linux option to your BOOT.INI file for you. Voila! Done! Or, if you want to edit the exact message (such as "Slackware Linux", etc.) you can just add the line

  c:\bootsect.lnx="Slackware Linux"
Either way, this should bring Linux into the picture. Then, when you select your new Linux option, it should fire up LILO with the LILO options you set up previously.


ADDING OTHER OPERATING SYSTEMS TO THE BOOT.INI FILE

As I said at the top of this explanation, I fully expect that this procedure should work for OS/2 or FreeBSD or whatever other operating system you want to insert, given that it can be made to boot the given operating system without trashing the master boot record. BOOTPART is ideal for this; in fact, I believe it even comments on the steps necessary to add OS/2 Boot Manager partitions. Still, because I don't personally own any Big Blue operating system, I have to say experiment at your own risk. If you have sections to add to this HOWTO, please mail them to me and I will include them.


REPAIRING YOUR NT INSTALLATION

Here's how to repair your NT bootup files (from Microsoft KnowledgeBase articles Q102793 and Q104429):

NOTE: BE SURE YOU HAVE A BOOTABLE "NT SETUP DISK 1" BEFORE STARTING! AFTER EXECUTING "SYS" AND BEFORE BOOTING SETUP, NT CANNOT BE BOOTED!

  1. Be sure that the last system you ran from the hard disk was DOS (to ensure the proper files are replaced in step 3 below). THIS IS IMPORTANT! To be sure, you may want to boot DOS via Win95 before continuing.
  2. Boot DOS from the bootable diskette that contains the MS-DOS program SYS.COM (and the program fdisk if you are going to remove LILO from your Master Boot Record).
  3. If you have LILO installed in the Master Boot Record, use the following command to remove it:

    FDISK /MBR

  4. From the bootable disk in drive A, use the following command to remove the Windows NT boot sector:

    SYS C:

    You should receive a "System Transferred" message.

    SYS.COM replaces the partition boot sector, which loads NTLDR, with an MS-DOS boot sector that loads MSDOS.SYS and IO.SYS. SYS.COM also replaces IO.SYS, MSDOS.SYS, and COMMAND.COM in the root of C:. This is why DOS should have been the last system run from the hard disk (so that the files named MSDOS.SYS, etc. are the DOS versions, not the Win95 versions). IF YOU LAST RAN WIN95, YOU WILL OVERWRITE THE WIN95 VERSIONS!
  5. Reboot the system with the Windows NT Setup Disk number 1 in drive A.
  6. When prompted with "To repair a damaged Windows NT Version 3.51 installation, press R", enter R for Repair. Follow the prompts, answering questions regarding the hardware configuration with what is reasonable for your system.
  7. Setup will eventually prompt with the following repair options in a box:

    [x] Inspect registry files
    [x] Inspect startup environment
    [x] Verify Windows NT system files
    [x] Inspect boot sector
    Continue (perform selected tasks)

    Alter the options so that only the last one, "Inspect boot sector" is checked. Then choose "Continue". (The "Inspect boot sector" option used to be called "Verify boot files".)
  8. When setup prompts "If you have the Emergency Repair Disk, press ENTER", you may hit ESC to locate the "previous" (i.e., your working copy) of NT. You do not need the Emergency Repair Disk, though you may use it (it does not matter; setup is not going to use it).
  9. Setup will replace the DOS boot sector with the NT boot sector, and store the DOS boot sector in BOOTSECT.DOS. It will then tell you to reboot your system.

WHY IT WORKS

When you start the system, the first sector of the active disk partition is loaded into memory and executed. This sector is called the "boot sector" and is physically located "outside" of the FAT file system on drive C: (for a more comprehensive discussion, see the Microsoft KnowledgeBase article Q101787, "General Information on Starting Multiple Operating Systems"). If you can boot NT, then the boot sector is the "NT boot sector", which loads and runs the program NTLDR, which presents the multiboot menu.

When DOS was installed, it put its own boot sector in that loads IO.SYS.

When NT was installed, it overwrote DOS's boot sector with its own (the NT boot sector) after copying the DOS boot sector to a file called BOOTSECT.DOS in the root of C:. When you selected "MS-DOS" from the NT boot menu, NTLDR would run BOOTSECT.DOS, which would load IO.SYS, and DOS would boot.

When Win95 was installed, it left the NT boot sector in place, but overwrote BOOTSECT.DOS with its own boot sector (the "Win95 boot sector") which also loads IO.SYS. Win95 also wants to install its own IO.SYS and MSDOS.SYS, which conflicts with the DOS versions. So it renames DOS's IO.SYS and MSDOS.SYS to IO.DOS and MSDOS.DOS.

Since DOS and Win95 each expect their system files to be *.SYS, their respective IO.SYS and MSDOS.SYS files must be renamed back and forth as the two systems are booted. Therefore:

(Why Win95 renames its IO.SYS to WINBOOT.SYS instead of IO.W40, I do not know).

The Win95 IO.SYS will perform this renaming when you select "Previous version of MS-DOS", but apparently uses an internal loader to perform the equivalent of the DOS boot sector.

NTLDR will also perform the renaming (with the /WIN95 and /WIN95DOS switches) but still needs an external BOOTSECT file to boot DOS.

You can verify which boot sectors are in which file by examining the files with a hex dump program (or use the NT command "DEBUG"). Look at the first few bytes and also at the last few bytes for the following strings:

First bytes           Last bytes            Operating System
--------------------  --------------------  ----------------
MSDOS5.0              IO SYSMSDOS SYS       DOS
MSDOS5.0              NTLDR                 NT
MSWIN4.0              WINBOOT SYS           Win95

Why Bother?

I think that operating systems are starting to become as hot a topic of contention as politics and religion, but they don't have to be. I personally believe that there is still no single "perfect operating system." But there is no reason you can't use the right OS for the right job. So it makes sense to have as many operating systems as it takes for you to be able to do what you want to do. I hope that this reference will let you do that.



USING NT DEBUG TO VIEW THE BOOTSECT FILES

  1. Open a console window under NT.
  2. Change the current directory to the root of C:.
  3. Enter the command "debug bootsect.dos" (or "debug bootsect.w40").
  4. At the "-" prompt, enter the command "d 100 L 100" to see the first half of the file.
  5. At the "-" prompt, enter the command "d 200 L 100" to see the second half of the file.
  6. At the "-" prompt, enter the command "q" to quit back to the command prompt.

Urgent warning for Norton Utilities for Win95 Users!!

Note: If you use Norton Speedisk, then add IO.SYS and MSDOS.SYS to the unmovable file list, or else you will no longer be able to boot DOS. Basically, DOS 6.x and before expect IO.SYS and MSDOS.SYS to be the first entries in the file list on the boot partition, but since DOS 7 doesn't care, Norton Speedisk doesn't care either. IT WILL MOVE THEM! And if this happens, DOS will panic! So make these files unmovable or you'll be sorry....



Does this work with NT 4.0?

The answer to that question is that I have not tried it yet (I'm waiting on my copy of NT 4 to be shipped to me), but I see no reason why it wouldn't. As soon as I have a chance to try it for myself, I'll post my results.



REFERENCES




IF ALL ELSE FAILS....

I have run through all of this on my system, and it works. However, I have not tested it on any other configuration. Also, I may not have thought of every contingency. That is why you made backup files! In general most everything that this procedure alters can be fixed (at least back to its original state) by backing up files and having original installs and emergency repair disks at the ready.

Still, if something does not work right, and the solution is not obvious, restore your backup files and e-mail me a description of the problem. I will try to get back to you as soon as possible.

Also please note that I have not performed an exhaustive examination of the operation of the NT or Win95 boot process, so there may be factual errors in my explanations. I have investigated just enough to get the process to work for me, and I try to investigate scenarios that people bring to me: Corrections are welcomed.

Good luck!

Sean Edmison <sedmison@rice.edu>

Last updated: 3 November 1996