phamtuananh10-07-2006, 11:02 m�nh search tr�n m?ng th?y c�i n�y, b?n xem th? xem! direct boot into winnt/win95/dos j. david bryan, palomar corporation september 15, 1995 revised january 29, 1998 -------------------------------------------------------------------------------introduction it is possible to boot directly into each of the three operating systems using the windows nt 4.0 or 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. the two required conditions to do this 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"). note: these instructions assume that you have already installed nt, win95, and dos on your system, that all three successfully boot from the nt boot loader menu (dos is booted by booting win95 and selecting "previous version of ms-dos" from the win95 boot loader menu), and that you now want to modify the nt boot loader menu to be able to boot dos without first booting win95. these instructions are not specifically intended as a guide to installing these operating systems, although much of the information will be useful. note also: the osr2 version of windows 95 is not intended for use on a system with dos; it is intended to be installed on new systems instead of dos. therefore, it does not support booting to the "previous version of ms-dos" (although this option may still be enabled and used, it will crash your system if you attempt to use it -- see microsoft knowledgebase article q155364, titled "osr2 hangs after booting previous operating system", for details). depending on your installation requirements, you may find the following additional articles of use: dual-booting windows nt and dos/win95 when c: is ntfs installation considerations for triple-booting winnt/win95/dos (includes osr2 information) an alternate and more automatic method of creating the boot sector files needed to boot multiple operating systems uses a program called bootpart by gilles vollant. see his bootpart page for details on this program (and please send all bootpart questions to gilles -- i have never used the program). -------------------------------------------------------------------------------my system i have nt 4.0 workstation, nt 3.51 workstation, win95, and dos 6.22 (with wfw 3.11, though this does not matter). as i have been upgrading each system as it was released, i first installed dos, then nt 3.51, then win95, then nt 4.0 (in that order).
my primary (bootable) partition is the first partition of the first hard drive (this is drive c:) which is fat16. i have each system on a separate partition, though this is not required -- it is just easier if i need to wipe out a system and start again. 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 ...plus 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 i installed each operating system to a separate directory. -------------------------------------------------------------------------------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 v4.0") with (at least) these choices: windows nt 4.0 windows 95 dos 6.22 and when you select a choice, you will then see one of the following messages at the top of the screen (depending on which system you select): ntdetect v4.0 checking hardware starting windows 95... starting ms-dos... -------------------------------------------------------------------------------what you need to do the steps needed to implement direct boot are: edit boot.ini to add separate choices for win95 and dos. make available separate win95 and dos boot sector files. -------------------------------------------------------------------------------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). 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 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). 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 boot sector files and verify their correctness. -------------------------------------------------------------------------------how you do it (the following procedure can be used from any of the available systems; i used nt.) to get the "correct" system files (with the correct names), edit the boot.ini file (hidden and read-only) present in 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 4.0" 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.dos="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 always belong to the "current" operating system.) note that the /win95 and /win95dos switches are only recognized by ntldr versions 3.51 and later. 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. however, after your win95 installation, bootsect.dos contains the win95 boot sector, not the dos boot sector. therefore, rename bootsect.dos to bootsect.w40. 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 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. that is it! you should now be able to boot directly into dos, win95, or nt from the multiboot menu. important note: step 1 above depends on a feature of the "upgrade" version of win95 (i.e., the version that upgrades a dos installation to a win95 installation). microsoft has also released several "new system" versions (for installation on systems that never had dos) -- osr2 falls into this category, as do some oem versions of win95. in these latter versions, microsoft removed the capability to boot to the previous version of dos, as they assumed there was no previous version (otherwise, you would have bought the "upgrade" version). although the instructions above assume that you have the "upgrade" version of win95 on your system, they can be made to work with "new system" versions. in lieu of step 1 above, boot from a dos diskette and manually rename the following win95 files in c:\ on your hard disk:
rename rename rename rename rename
io.sys to winboot.sys msdos.sys to msdos.w40 command.com to command.w40 (if present in c:\) autoexec.bat to autoexec.w40 (if present in c:\) config.sys to config.w40 (if present in c:\)
this will put your system in the same configuration as would booting to dos via win95 in the "upgrade" version of win95. then continue to follow steps 2-8 above. -------------------------------------------------------------------------------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 uses an internal loader to perform the equivalent actions 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 boots which 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. enter the command "debug c:\bootsect.dos" (or "debug c:\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. important note: you must create system boot sectors on the partitions on which they will be used. in general, you cannot simply copy a bootsect.dos file from another installation, because the boot sector contains an internal table (used to locate the root directory) that describes the physical layout of the drive and partition on which it was created (i.e., the number of heads, the number of sectors per track, the location of the partition in sectors from the start of the drive, the size of the file allocation table, etc.). this physical information will not, in general, be correct unless you are copying it from a system with an identical partitioning layout on an identical hard drive (not just the same capacity, but the same number of cylinders, heads, and sectors per track). -------------------------------------------------------------------------------additional notes i have run through this script 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! note that i have never used os/2 or linux, so i regret that i cannot offer advice or a way to integrate these operating systems into the direct boot process. bootpart by gilles vollant may help (remember to send all bootpart questions to gilles -- i have never used the program). i have been advised that a method of integrating linux into the nt boot loader is available through this link, but remember that i have never used linux, so i have no idea whether this method works or not. good luck!