China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-23 11:58
中国DOS联盟论坛 » DOS启动盘 & LOGO技术 (启动盘室) » [Reprint] Detailed Explanation of Making a Dual-boot USB Flash Drive for DOS and WinPE View 2,544 Replies 6
Original Poster Posted 2007-05-30 19:40 ·  中国 浙江 温州 电信
新手上路
Credits 4
Posts 1
Joined 2007-05-30 19:17
19-year member
UID 89791
Gender Male
Status Offline
Unexpectedly, the release of the production method has received such wide attention. It seems that everyone, just like me, hopes to make a relatively universal system maintenance tool. After the test feedback from netizens these days, it was found that the compatibility of the NT Loader + Avlgo method is not ideal. So I tried another boot method. Now I will also release the other two successful test methods for everyone to test and discuss together. I use this article to start a discussion, hoping that under the research of everyone, a relatively good compatibility solution can finally be found.

Previous:
Many years ago, when floppy drives were still a must-have for computers, floppy disks were also used to maintain the computer boot system. I made N pieces of boot floppy disks back then. Later, as floppy disks faded out of the market, system maintenance disks were also changed to CDs. For example, the famous Shenshan Hongye system maintenance tool disk provided strong help for my work. However, CDs still have disadvantages such as being easy to scratch and large in size. Now most computers basically support USB device booting, and USB flash drives can be made into small and easy-to-carry system maintenance disks; rewritable storage media also provide convenience for updates, and there is no need to burn a bunch of CDs for upgrades anymore.

Goal:
For system maintenance, Windows PE is an indispensable tool; in addition, some problems still need to be solved by booting into the DOS environment. So my goal is to make a DOS/WinPE dual-boot system maintenance USB flash drive. Next time when a computer system crashes, I can take out a delicate USB flash drive from my pocket, boot the computer, and solve the problem in a flash. How chic!

Technical background:
In fact, booting a computer from a USB flash drive mainly relies on the reasonable and flexible use of various boot tools. All operations and debugging are also centered around the installation and configuration of boot tools. We know that as the main carrier of the operating system, the disk has always been the most important storage medium. Therefore, basically all OS boot modes are roughly the same, and they are all loaded by the disk.
First, it is necessary to write specific boot code in the MBR (Master Boot Record) sector of the disk where the OS is located. After the computer boots, it will poll the MBR area of the corresponding disk according to the boot sequence set in the BIOS. If a valid MBR record is found, it will load the OS boot file according to the pointer of the MBR record. If the OS boot file is normal, the corresponding operating system will be loaded.
Therefore, to complete the boot of an operating system, two necessary steps are required: 1. MBR boot; 2. OS boot.
Based on the above basic principles, various operating systems have their own built-in boot loaders, such as NTLDR of Windows NT and above systems, Lilo of Linux, Grub boot loaders of various versions, etc. Of course, there are also some third-party multi-system boot tools such as System Commander, etc.
For our current application, the purpose is to be able to achieve dual-boot of DOS/WinPE on a USB flash drive and have relatively good compatibility. To achieve this goal, there are some technical requirements. First, the solution should be able to adapt to the disk letter change situation of USB flash drive mobile storage; second, to achieve dual-boot, a virtual disk image is generally used, that is, the boot loader needs to support the RAMDisk loading method for booting various common disk images.
Although USB flash drives have many advantages such as being small and lightweight and can be rewritten repeatedly, if they are to be made into boot disks, there are still some problems that need to be solved. The biggest problem is that there is no unified industry standard for USB booting. Different motherboard manufacturers and different BIOSs have different USB boot methods. As a mobile storage device, the motherboard's different recognition of USB flash drives will cause the disk letter to change. These directly lead to the poor universality and compatibility of USB flash drive booting, and the performance is that it cannot boot on some computers. This is a key problem to be solved.

OS selection:
The DOS system selects MS-DOS 7.1; the WinPE selects "Lao Maotao's WinPE final modified version with external network and multimedia components" from the Wuyou Forum.


Scheme 1: NT Loader + AVLDR + Avlgo

The MBR is booted by NT Loader. In the NTLDR boot menu, set options: boot WinPE with AVLDR; and boot DOS with Avlgo. Since Avlgo does not support multi-boot in the menu mode, in order to solve the problem of different disk letters recognized by USB flash drives on different motherboards, the Avlgo boot configuration file is slightly modified to adapt to the boot requirements of disk letter changes.

Tool preparation:
PeToUsb - used to format the USB flash drive into the NT boot mode; WinImage - used to make a DOS boot floppy disk image; Avlgomgr - used to generate Avlgo boot files; UltraEdit - used to edit and modify the Avlgo boot file.


Data preparation:
1. PeToUSB is a free software specially used to format the boot area of the USB flash drive into NTLDR boot code. Start PeToUSB, select the target USB flash drive from the "Destination Driver" column, click the "Start" button below, it asks whether to continue with "Continue", click "Yes", a warning window pops up, prompting that all data on the target disk will be lost, whether to continue? Still select "Yes", and then it is completed in a moment.




2. Use WinImage to make a 2.88M boot floppy disk image, load MS-DOS 7.1 into the image, and put common DOS tools into the image. After starting WinImage, click the leftmost button to create a new image, here select the standard format 2.88MB, in order to store as many tools as possible. Then add files to this image, drag the prepared MS-DOS system files from the resource manager to the WinImage window. Other DOS tools are added in the same way. After the files are added, click the "Image" menu - "Boot Sector Properties", select "Windows 95/98" and confirm. This step is very important. If this step is omitted, this floppy disk image cannot boot the computer. Finally, save it as an ima format image file DOS.ima.





3. First back up the Boot.ini file of drive C. Note that this system and hidden attribute file is not visible in the default state. It is necessary to modify the viewing method in the "Tools" menu "Folder Options" in the resource manager, cancel the "Hide protected operating system files" check box, and switch to show all files. Start Avlgomgr, browse and find the just-made image file with WinImage in the "Virtual Disk Full Path", then click the "Assemble" button, Avlgomgr automatically modifies the Boot.ini file, and generates the two key files Avldr.bin and Avlgo.sys we need on the target disk (in this example, drive C), and copy these two files to a place for later use. After completion, restore the original Boot.ini file of drive C.


4. Start UltraEdit, first open Avldr.bin, find the string "AVLGO.SYS" in the ASCII code area on the right of the editing screen, change it to "AVDOS.SYS", and save the file as Avldr.dos.



5. Then open Avlgo.sys, find the string "(hd0,0)/DOS.IMA" in the right ASCII code area, modify it to "(fd0)/DOS.IMA". When modifying, note that since the modified string is shorter than the original one, to ensure that the file length remains unchanged, the remaining part should be switched to the left hexadecimal code area and filled with "00", so that the file length can be ensured to remain unchanged. After modification, save it as Avdos.sys.




Start assembly:

1. First, create a Boot.ini file in the root directory of the USB flash drive with Notepad. The content is as follows:

timeout=30
default=C:\avldr.xpe

C:\avldr.xpe="Windows PE By:LaoMaotao"
C:\avldr.bin="MS-DOS 7.1 form USB-HDD"
C:\avldr.dos="MS-DOS 7.1 from USB-FDD"
After completion, modify the attributes of this file to read-only/system/hidden (you can use the DOS command attrib +r +s +h boot.ini to modify the file attributes).
This is the menu configuration file of NT Loader. The timeout parameter sets the menu waiting time. If the user does not make a selection within the set time (30 seconds in this example), it will automatically load the default item C:\avldr.xpe set by default and start WinPE.
The section is the boot options that appear in the menu. The first one is the Lao Maotao WinPE set by the previous default. The text in double quotes is a comment line and will be displayed in the boot menu. The next two lines are the boot items corresponding to the two modes of the motherboard recognizing the USB flash drive as USB-HDD and USB-FDD respectively.

2. Copy the NTLDR and NTDETECT.COM files of the hard disk system to the root directory of the USB flash drive. These are the necessary files of the NT Loader boot loader.

3. Extract the ISO file of Lao Maotao WinPE downloaded to a temporary folder, copy AVLDR.XPE in the "WINPE Installation" folder to the root directory of the USB flash drive, copy SETUPLDR.BIN in the "WXPE" folder to the root directory of the USB flash drive and rename the file to LDRXPE. Copy WINNT.XPE, WINPE.IS_, and the "External Programs" folder in the temporary folder to the root directory of the U flash drive. After doing this step, the USB flash drive can boot to WinPE. If the first item "Windows PE By:LaoMaotao" is selected during startup, the system will start the computer to the Windows PE environment in the order of NTLDR------>avldr.xpe------>winnt.xpe------>winpe.is_.

5. Copy the floppy disk image file DOS.ima to the root directory of the USB flash drive.

6. Copy the two files Avldr.bin and Avlgo.sys generated earlier to the root directory of the USB flash drive. According to the Boot.ini file, these two files correspond to the second line in the menu for the USB-HDD mode. If the second item "MS-DOS 7.1 form USB-HDD" is selected during startup, the system will start the computer to the MS-DOS environment in the order of NTLDR------>avldr.bin------>avlgo.sys------>DOS.ima.

7. Copy the two files Avldr.dos and Avdos.sys edited and generated by UltraEdit earlier to the root directory of the USB flash drive. According to the Boot.ini file, these two files correspond to the third line in the menu for the USB-FDD mode. If the third item "MS-DOS 7.1 form USB-FDD" is selected during startup, the system will start the computer to the MS-DOS environment in the order of NTLDR------>avldr.dos------>avdos.sys------>DOS.ima.

At this point, the DOS/WinPE dual-boot system maintenance USB flash drive is successfully made.

Scheme 2: NT Loader + Grub4DOS

Because the Avlgo boot loader does not support multi-configuration menu by default, so I used a special method to edit and process the Avlgo boot configuration file earlier, in order to solve the problem of disk letter changes of USB flash drive booting. According to the feedback from netizens, the failure rate of booting the DOS boot floppy disk image in this way is still relatively high. Basically, the situation where the problem occurs is that the NT Loader boot is normal, but an error occurs at the Avlgo link. Therefore, in this solution, NT Loader is still retained as the MBR boot loader, and Grub4DOS is used to boot the OS.

1. Write the MBR of the USB flash drive with NTLDR. This work can be completed with PeToUSE or other methods to achieve the goal. For specific operations, see Scheme 1.

2. Copy the files NTLDR and NTDETECT.COM required by NT Loader to the root directory of the USB flash drive.

3. Edit the NT Loader boot menu Boot.ini. Create a Boot.ini file with any text editor. The content is as follows:

timeout=0
default=C:\grldr

C:\grldr="Boot Menu"
For the meaning of each item in the Boot.ini menu, please refer to the description in Scheme 1.

4. Copy the Grub4DOS file, copy grldr in Grub4DOS to the root directory of the USB flash drive; create a Boot folder in the root directory of the USB flash drive, and copy the Chinese font file Fonts.tz and the menu background image file Splash.gz in Grub4DOS to this folder. Create a grubidx.txt file in the root directory of the USB flash drive. The content is irrelevant.

5. Copy the DOS floppy disk image file dos.ima to the Boot folder of the USB flash drive.

6. Copy the WINNT.XPE and WINPE.IS_ files in Lao Maotao WinPE to the root directory of the USB flash drive; copy SETUPLDR.BIN in the WXPE folder to the root directory of the USB flash drive and rename it to LDRXPE. Note that there is no suffix. Copy the "External Programs" folder to the root directory of the USB flash drive.

7. Create a Grub boot menu file. Use any plain text editor to create a Menu.lst file in the root directory of the USB flash drive. The content is:
timeout 30
default 0
splashimage /boot/splash.gz
foreground ffff00
fontfile /boot/fonts.gz

title 启动 WindowsPE
find --set-root /grubidx.txt
chainloader /ldrxpe

title 启动 MS-DOS 7.1
find --set-root /grubidx.txt
map --mem /boot/dos.ima (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
After doing these, the USB flash drive can be booted.

Menu item description:
The first line sets the waiting time of 30 seconds;
The second line sets that if the user does not make a selection within 30 seconds, it will default to starting the first boot item "Start WindowsPE";
The splashimage item sets the background image of the Grub4DOS boot menu. The image path is /boot/splash.gz;
The foreground item sets the boot menu text color to bright yellow;
The fontfile item sets the Chinese font file to /boot/fonts.gz
The following two sections starting with title are the two boot items of the boot menu. The text after title will be displayed in the menu;
find --set-root /grubidx.txt is to automatically search for the previously created feature file grubidx.txt. As long as it finds this file, it will set the path where the file is located as the root device, so as not to be troubled by disk letter changes. As for the content of the feature file, it doesn't matter.
chainloader /ldrxpe is to start the XPE image of WinPE.
map --mem /boot/dos.ima (fd0) is to load the /boot/dos.ima floppy disk image and virtualize it as fd0.
map --hook is to make the loaded floppy disk image take effect immediately.
rootnoverify (fd0) specifies to set the just virtualized fd0 as the root device.

Originally, Grub4DOS can be directly installed in the root directory of the USB flash drive, but I tried many times, the MBR was written in, but it always reported an error and could not boot. So still use NT Loader as the MBR boot loader. Since NT Loader does not support loading image files, after the MBR boot is successful, the control is handed over to Grub4DOS, and Grub4DOS is used to load the XPE image of WinPE and the floppy disk image of MS-DOS to realize the function of booting the corresponding OS.

Scheme 3: MS-DOS 7.1 + Grub4DOS

Originally, this scheme was the earliest scheme I used to make a dual-boot USB flash drive, but it always couldn't be used on my ASRock 845E motherboard, so it wasn't released at the beginning. This time it is released for everyone to test, see if it is a special case of my motherboard.
The MBR of this scheme is booted by DOS, and WinPE is loaded and started by Grub4DOS. Compared with the previous scheme, this scheme is the simplest to make.
1. Use HP USE Disk Storage Format Tool to format the USB flash drive into a FAT bootable disk.
2. Copy other DOS files and some DOS tools to the USB flash drive according to your needs.
3. Copy the WINNT.XPE and WINPE.IS_ files in Lao Maotao WinPE to the root directory of the USB flash drive; copy SETUPLDR.BIN in the WXPE folder to the root directory of the USB flash drive and rename it to LDRXPE. Note that there is no suffix. Copy the "External Programs" folder to the root directory of the USB flash drive.
4. Copy the two files NTLDR and ntdetect.com to the root directory of the USB flash drive. These are the necessary files to start the XPE format WinPE image.
5. Copy the two program files grub.exe and fonts.gz of Grub4DOS and the Chinese font file to the root directory of the USB flash drive.
6. Use any text editor to create Menu.lst in the root directory of the USB flash drive. The content is as follows:
timeout 0
default 0
fontfile /fonts.gz

title 启动 WindowsPE
find --set-root /grubidx.txt
chainloader /ldrxpe
Create a grubidx.txt file in the root directory of the USB flash drive. The content is irrelevant. The function is to cooperate with Menu.lst as a Grub feature file to find and determine the root device.
7. Edit Config.sys and Autoexec.bat by yourself, build a DOS multi-boot menu, and add the item to start Grub4DOS. It is necessary to ensure that no memory management program and other drivers and resident programs are loaded when starting Grub, so as not to conflict with Grub4DOS. You can simply add a line in Autoexec.bat:
grub
In this way, Grub4DOS can be started. Of course, in order to achieve dual-boot, these two configuration files need to be edited into a multi-menu mode, and the corresponding configuration can be started when needed. I put my configuration file content below for reference.
Content of Config.sys:

MENUITEM=1,XMS without CD-ROM support
MENUITEM=2,XMS with CD-ROM support
MENUITEM=3,XMS and EMS
MENUITEM=4,DOS real mode(no XMS,no EMS)
MENUITEM=5,Windows PE
MENUDEFAULT=5,30

DEVICE=\HIMEM.SYS /TESTMEM:OFF
DEVICE=\EMM386.EXE NOEMS
INCLUDE=PUB

DEVICE=\HIMEM.SYS /TESTMEM:OFF
DEVICE=\EMM386.EXE NOEMS
DEVICEHIGH=\VIDE-CDD.SYS /D:SSCD001
INCLUDE=PUB

DEVICE=\HIMEM.SYS /TESTMEM:OFF
DEVICE=\EMM386.EXE RAM
INCLUDE=PUB

DOS=HIGH,UMB
FILES=30
BUFFERS=20
STACKS=9,256
LASTDRIVE=Z

FILES=10
BUFFERS=10
LASTDRIVE=Z


Content of Autoexec.bat:
@ECHO OFF
PATH=A:\;C:\;A:\Diskgen;C:\DiskGen;A:\DM;C:\DM
GOTO %CONFIG%
:1
GOTO COMMON
:2
LH \SHSUCDX.COM /D:SSCD001
GOTO COMMON
:3
GOTO COMMON
:4
GOTO END
:5
GRUB
:COMMON
LH \SMARTDRV.EXE /X
@ECHO Install mouse driver?
\CHOICE /C:YN Yes,No /T:N,6
IF ERRORLEVEL 2 GOTO END
LH \MOUSE.COM
:END
According to this configuration, if the 5th item is selected during startup, or no selection is made within 30 seconds and the 5th item is automatically executed, then Grub4DOS will be started via the corresponding statement in Autoexec.bat, and then Grub4DOS will start WinPE according to the settings of Menu.lst. For the specific practice of the DOS multi-boot configuration, please refer to relevant information.

Thanks to 5free and david_ge for their help!

The "Lao Maotao's WinPE final modified version" selected in this article can be downloaded from the Wuyou Forum or Lao Maotao's network disk:
http://bbs.wuyou.com/viewthread.php?tid=94087
http://maotao.u.winzheng.com/
The Avdos.rar in the attachment is the Avlgo boot file I made; the NTLDR.rar is the NT Loader boot loader file; the PeToUSB.rar is the tool to format the NTLDR boot disk; the Avlgomgr2007.rar is the Avlgo assembly tool; the FixNTBoot.rar is another tool to write the NT Loader MBR. Other software involves copyright, please find it on the Internet by yourself.


Recently, I have been researching the DOS/WinPE dual-boot USB flash drive. At the beginning, I used Grub for DOS, but this thing has compatibility problems with USB device support, causing some motherboards to freeze when loading WinPE.
Later, I used NTLDR+AVLDR to replace Grub for DOS to solve the WinPE compatibility problem.
The current problem to be solved is how to boot DOS with NTLDR. Now I put the DOS files in the root directory of the USB flash drive, and have extracted and generated the boot sector file for formatting the USB flash drive into the DOS boot mode. But I don't know how to write the Boot.ini file, and whether I still need to make the DOS system files into a certain image?
Floor 2 Posted 2007-09-03 10:05 ·  中国 广西 南宁 西乡塘区 电信
中级用户
★★
Credits 259
Posts 164
Joined 2006-09-21 23:39
19-year member
UID 63296
Status Offline
Floor 3 Posted 2007-09-05 13:32 ·  中国 广西 桂林 电信
新手上路
Credits 6
Posts 3
Joined 2007-08-21 10:58
18-year member
UID 95487
Gender Male
Status Offline
Cow............................
Floor 4 Posted 2007-09-18 14:01 ·  中国 上海 图像数据通信有限公司
新手上路
Credits 4
Posts 2
Joined 2007-09-18 10:24
18-year member
UID 97679
Gender Male
Status Offline
Good post
Floor 5 Posted 2007-09-22 20:44 ·  中国 江苏 徐州 中移铁通
初级用户
Credits 73
Posts 36
Joined 2007-09-20 22:08
18-year member
UID 97917
Gender Male
Status Offline
Powerful, I didn't understand it for a while... Take my time to read
Floor 6 Posted 2007-09-26 17:33 ·  中国 四川 成都 电信
新手上路
Credits 10
Posts 5
Joined 2007-09-26 15:18
18-year member
UID 98319
Gender Male
Status Offline
Strong, made stronger~ ~
Floor 7 Posted 2007-09-28 08:30 ·  中国 广东 珠江宽频
新手上路
Credits 4
Posts 2
Joined 2007-09-27 23:25
18-year member
UID 98436
Gender Male
Status Offline
Forum Jump: