Multiboot directly into WinNT/Win95/DOS/Linux from the NT Boot Loader DIRECT BOOT INTO WinNT/Win95/DOS/Linux from the NT Boot Loader 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 for additional information about the Unix dd command. 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)_. 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: -- The correct system files must be present with the required names. -- 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: -- BOOTSECT.DOS -- BOOT.INI -- NTDETECT.COM -- NTLDR If you have Windows 95 installed, then you should also have the following files if DOS was booted more recently than Win95: -- IO.SYS -- MSDOS.SYS -- MSDOS.W40 -- WINBOOT.SYS or the following files if Win95 was booted more recently than DOS: -- IO.DOS -- IO.SYS -- MSDOS.DOS -- MSDOS.SYS If you have not installed Windows 95 yet, then you should just have the following DOS files: -- IO.SYS -- MSDOS.SYS Finally, I have a Linux bootsector file that points to the volume on which I have installed Linux (with LILO): -- BOOTSECT.LNX (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: -- "Windows NT 3.51" -- "Windows 95" -- "DOS 6.22" -- "Linux" and when you select a choice, you will then see one of the following messages on the screen (depending on which system you select): -- "NTDETECT V1.0 Checking Hardware" -- "Starting Windows 95.." -- "Starting MS-DOS..." -- "LILO..." BEFORE YOU START -- Make backups of the files BOOT.INI and BOOTSECT.DOS in the root of C: BOOT.INI is hidden; BOOTSECT.DOS may be). -- It's not a bad idea to have a backup of your Linux lilo.conf file (usually /etc/lilo.conf). -- Be sure you have BOOTABLE Windows NT Setup Diskettes (three diskettes). If not, run "winnt32 /o" from the installation CD to make them. -- 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). -- Be sure you have the Windows 95 installation disks or CD-ROM handy. -- Be sure you have your Linux boot/root disk(s) handy. -- If you have not installed Windows 95, be sure that you can load DOS and Windows NT. -- 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). -- Be sure you can start Linux (with LILO). 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.) -- 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 direct boot are: -- Make available separate Win95, DOS, and Linux boot sector files. -- Edit BOOT.INI to add separate choices for Win95, DOS, and Linux. 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 Win95 If you already have Win95 and WinNT 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. (There is a difference.) 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 you need a BOOTSECT.DOS that contains a DOS boot sector. Fortunately, NT will make one for you. Unfortunately, you have to go through about 10 minutes of the setup program for it to generate the BOOTSECT.DOS (which takes about 1 second). Here's how (from the 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! -- 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. -- Boot DOS from the bootable diskette that contains the MS-DOS program SYS.COM. -- 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! -- Reboot the system with the Windows NT Setup Disk number 1 in drive A. -- 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. -- 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".) -- 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). -- 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. 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 Win95 will OVERWRITE the boot sector file if you reinstall it, and NT will under some circumstances rewrite the BOOTSECT.DOS file (because this 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 without Win95 Alternately, if you're setting up a machine from scratch or you just haven't installed Win95 yet, 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 because Win95 will OVERWRITE the boot sector file if you install or reinstall it, and NT will under some circumstances rewrite the BOOTSECT.DOS file (because this is the default filename). So you can just copy this file to BOOTSECT.622 or some other name that you'll remember. CREATING THE WINDOWS 95 BOOT SECTOR FILE If you don't yet have a Win95 boot sector file (by backing one up in the process above), then the way to create one is to install or resurrect Windows 95 (by running Win95 setup from DOS and telling it to install or repair an installation as appropriate). Once Win95 setup completes, the BOOTSECT.DOS file in the bootup directory will be the Win95 boot sector file. Save this file as BOOTSECT.W40 or BOOTSECT.W95 or some other filename that you will remember as being the Win95 boot sector. CREATING THE LINUX BOOT SECTOR FILE> So far so good? Right now the machine loads DOS (indirectly), Win95, and 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 mix. 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. 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 OOTSECT.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: ...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 That's all there is to it. This way, you won't have to keep writing a bootsector on your Linux partition with LILO and then saving it to a separate file each time you install a new kernel. 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 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 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 and 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. 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: -- After booting Win95, DOS's IO.SYS and MSDOS.SYS become IO.DOS and MSDOS.DOS -- After booting DOS, Win95's IO.SYS and MSDOS.SYS become WINBOOT.SYS and MSDOS.W40 (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 USING NT DEBUG TO VIEW THE BOOTSECT FILES -- Open a console window under NT. -- Change the current directory to the root of C:. -- Enter the command "debug bootsect.dos" (or "debug bootsect.w40"). -- At the "-" prompt, enter the command "d 100 L 100" to see the first half of the file. -- At the "-" prompt, enter the command "d 200 L 100" to see the second half of the file. -- 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.... 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 edited: 26 June 1996