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 08:51
中国DOS联盟论坛 » GRUB4DOS、SYSLINUX及其它启动管理软件讨论专区 » A Beginner's Tutorial on grub4dos - Application Section [Full Text Completed] View 5,756 Replies 23
Original Poster Posted 2007-03-14 02:02 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Please see the latest updated version: grub4dos Beginner's Tutorial - Introduction Chapter, Application Chapter
http://www.cn-dos.net/forum/viewthread.php?tid=28300&fpage=1

Description: Update some content. For easy reading, merge "Introduction Chapter" and "Application Chapter". The PDF graphic version can be downloaded from my network disk or from the Space Forum. (It seems that the site can no longer attach files currently)

-------------------------------------------------

grub4dos Beginner's Tutorial - Application Chapter

lianjiang 2007.03.14 Second Revision

1 Application on Hard Disk
2 Application on CD
3 Application on Floppy Disk
4 Application on USB Flash Drive
5 Conclusion
6 Acknowledgments

Note: 1) Many materials cited in this tutorial are from the Internet, and the copyright belongs to the original website or the original author.
2) Please refer to "grub4dos Beginner's Tutorial - Introduction Chapter" first.
3) The application environment is Windows/DOS.
4) I have just come into contact with grub and have a very superficial understanding of grub. Please point out any errors.

******************************************************************

1 Application on Hard Disk

To apply grub on a hard disk, you first need to install it. The installation/booting methods are mainly 3 types, namely a, enter grub4dos through the boot menu of Windows NT; b, boot grub through DOS; c, boot grub through MBR.

After installing grub, you need to prepare the menu file menu.lst.

1.1 Loading Floppy Disk Image

For Windows users, using grub to load a floppy disk image is one of the most commonly used functions. Since Windows 2K/XP has been separated from DOS, performing some operations under DOS such as system backup/recovery has become a difficult problem for beginners. Previously, we might need to use a boot CD, etc., to enter DOS. The characteristics of the CD determine that it is difficult to update the tools on the CD in a timely and convenient manner. The appearance and application of grub have solved this problem. We can not only enter the DOS environment without using other media, but also update tools in a timely manner. Many of the various system maintenance tools downloaded from the Internet are in img format. Without extracting the files, we can use them by slightly modifying menu.lst, and various tools can coexist harmoniously, which is very convenient to use.


How to add the downloaded xxx.img to the grub boot menu?
You just need to save xxx.img to the C:\boot\grub directory, edit menu.lst, and add the following content.
title Boot from Floppy image XXX
map --mem /boot/grub/xxx.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

Note: These lines of content cannot be added at the very beginning because the previous ones are some settings that are effective globally.

All the tools you need can be added in this way.

Maybe you have many tools, and adding them all to the menu will make it messy. Usually, there may be only one or two commonly used tools, and many are only used occasionally. For this situation, you can take the following method. That is, write the commonly used ones into the menu, and at the same time write the content of a general startup img file in the menu. For example, the above

title Boot from Floppy image XXX
map --mem /boot/grub/xxx.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

In this way, after starting grub and entering the menu, select "Boot from Floppy image XXX", press "e" to enter the editing state, move the direction keys, modify xxx.img to the file name you need to start, press Enter, and press "b" to start. (If the img file is saved in another path, change it to the corresponding path.)


1.2 Booting WinPE

Some system maintenance operations are not convenient or even cannot be performed under DOS. The appearance of WinPE has brought us a lot of convenience. The following takes the widely praised光棍版 WinPE modified by LaoMaotao as an example to introduce how to use grub to boot WinPE. (The光棍版 WinPE already has an installation program. Here, I will introduce adding a general winpe option in menu.lst.)

Steps: 1. Download the光棍版 WinPE, extract it to get BootCD.ISO.
2. Use a virtual CD-ROM or UltraISO, etc., to extract WINPE.IS_, WINNT.XPE, and WXPE\SETUPLDR.BIN from the ISO, copy these 3 files to C:\, and rename SETUPLDR.BIN to ldrxpe. If external programs are needed, also copy XPEMENU.INI and the "external program" directory to the root directory of any disk.
3. Add the following in menu.lst
title Micro Windows XPE (by LaoMaotao)
chainloader /ldrxpe

In this way, when you start grub and select "Micro Windows XPE (by LaoMaotao)", you can boot WinPE.


1.3 Booting Systems

For a single hard disk with multiple systems installed and multiple hard disks with multiple systems installed, grub can be used to conveniently manage the booting of each system.

For example, you can add the following options in menu.lst:

title Boot the operating system on the first primary partition (hd0,0) of the first hard disk
rootnoverify (hd0,0)
makeactive
chainloader +1

title Boot the operating system on the second primary partition (hd0,1) of the first hard disk
rootnoverify (hd0,1)
makeactive
chainloader +1

title Boot the operating system on the first primary partition (hd1,0) of the second hard disk
rootnoverify (hd1,0)
makeactive
chainloader +1

title Boot Windows NT/2000/XP/2003
find --set-root /ntldr
chainloader /ntldr

title Boot Microsoft Windows Vista
find --set-root /bootmgr
chainloader /bootmgr

title Boot DOS/Windows 95/98/Me
find --set-root /io.sys
chainloader /io.sys

******************************************************************

2 Application on CD

The following introduces two methods to apply grub on a CD.

2.1 Bootable CD guided by grub

Use grldr as the boot file of the CD to guide the CD, load menu.lst, and select the boot item through the menu.

Steps: 1) Prepare necessary img files, and grldr, menu.lst (prepare font, background image, memdisk.gz, etc., files as needed).

2) Edit menu.lst. The format to guide the img file on the CD is as follows:

title Win98 (MAP-HOOK-1)
map --mem (cd)/boot/grub/win98.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

The menu can also guide the img file on the hard disk, for example:

title GreenGhost (MEMDISK)
kernel (hd0,4)/boot/grub/memdisk.gz c=200 h=2 s=36 floppy
initrd (hd0,4)/boot/grub/gghost.img c=200 h=2 s=36 floppy

3) Organize files. For example, create a grubcd directory under E:\temp, copy menu.lst to this directory, and the menu.lst file will be in the root directory of the CD. Create a boot\grub directory under this directory to save various img, font, etc., files. Note: The file names of all files referenced in menu.lst that are displayed on the hard disk need to be lowercase, and uppercase ones need to be changed to lowercase.

4) Make ISO. Use UltraISO to create a new ISO file, add all files in the E:\temp\grubcd directory to the ISO file; perform "Boot CD" - "Load Boot File", select the grldr file. Then perform "File" - "Properties", select the "Allow lowercase letters" option, and save the ISO file.
You can also use tools such as mkisofs.exe or CDIMAGE.EXE to make a bootable ISO.

5) Burn the made bootable ISO with Nero, etc. If conditions permit, you can test it in a virtual machine first and then burn it, or use CD-RW/DVD+RW to burn it.



2.2 Bootable CD with BCDW guiding GRUB

This method is to use BCDW to make a bootable CD, and execute grub through BCDW to load the grub menu.

Steps: 1) First download the BCDW software package, extract it to get the required files.

2)Organize files. For example, create a bcdwcd directory under E:\temp. The files in this directory will be in the root directory of the CD. Create a boot\grub directory and a bcdw directory under it. Copy bcdw.bin, bcdw.ini, and loader.bin from the bcdw directory in the software package to the created bcdwcd\bcdw directory; copy grldr, various img, font, etc., files to the bcdwcd\boot\grub directory. The editing method of the menu.lst file is the same as introduced in 2.1 above.

3) Edit the bcdw.ini file. Open bcdw.ini, find the part, for example:



C:\ ; Boot from drive C:
\WNPE\setupldr.bin ; Bart's Preinstalled Environment
\I386\setupldr.bin ; Microsoft Windows XP Setup
\BCDW\bcdw2dos.ima \WIN9X\setup.exe ; Microsoft Windows 98 Setup

The above is an example of the BCDW boot menu. Add the grub item in it to become:



\boot\grub\grldr ; Grub4dos

C:\ ; Boot from drive C:
\WNPE\setupldr.bin ; Bart's Preinstalled Environment
\I386\setupldr.bin ; Microsoft Windows XP Setup
\BCDW\bcdw2dos.ima \WIN9X\setup.exe ; Microsoft Windows 98 Setup


4)The method of making the ISO file and burning the ISO is basically the same as in 2.1. The difference is that when making the ISO file, loader.bin needs to be used as the boot file of the ISO. You can also use tools such as mkisofs.exe or CDIMAGE.EXE to make a bootable ISO.

******************************************************************

3 Application on Floppy Disk

There are mainly two ways to apply grub on a floppy disk, namely booting grub through DOS and installing the GRLDR boot record to the boot sector of the floppy disk (for the installation method, refer to "grub4dos Beginner's Tutorial - Introduction Chapter").

3.1 Application of Floppy Disk Booted by grub through DOS

First, make the floppy disk into a bootable disk. The simplest way is that the floppy disk only needs three files: io.sys, msdos.sys, and command.com.

Then copy grub.exe and menu.lst to the root directory of the floppy disk.

Create a new autoexec.bat file, which only needs to write 4 letters.
grub

Then edit menu.lst. Due to the limited capacity of the floppy disk, it is generally difficult to directly call the img file on the floppy disk in the menu. Therefore, it can mainly be used to boot the img file on the hard disk and also to manage the booting of each system. The files with specified paths used in the menu file (such as fonts, img files, etc.) should be prepared in advance, otherwise the option cannot run. (There are also examples on the Internet of including many maintenance tools in the limited capacity of the floppy disk. Those who are interested can search by themselves.)

An example of the menu.lst file:


timeout 10

default 0

splashimage (fd0)/boot/grub/xp2008.gz

fontfile (fd0)/boot/grub/fonts

title GreenGhost (MAP-HOOK)
map --mem (hd0,4)/boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

title Find /menu.lst on the hard disk
find --set-root /menu.lst
configfile /menu.lst

title Boot the operating system on the first primary partition (hd0,0) of the first hard disk
rootnoverify (hd0,0)
makeactive
chainloader +1

title Boot the operating system on the second primary partition (hd0,1) of the first hard disk
rootnoverify (hd0,1)
makeactive
chainloader +1

title Boot the operating system on the first primary partition (hd1,0) of the second hard disk
rootnoverify (hd1,0)
makeactive
chainloader +1

title Reboot
reboot

title Shutdown
halt


3.2 Application of Floppy Disk with GRLDR Boot Record Installed in the Boot Sector


After the GRLDR boot record is installed, only grldr and menu.lst and the files referenced in menu.lst need to be retained on the floppy disk. The use of the menu.lst file is the same as in "3.1 Booting grub through DOS" on the floppy disk.


******************************************************************

4 Application on USB Flash Drive

To apply grub on a USB flash drive, it is similar to a floppy disk. There are mainly two ways, namely booting grub through DOS and installing the GRLDR boot record to the boot sector of the USB flash drive (for the installation method, refer to "grub4dos Beginner's Tutorial - Introduction Chapter").

First, use the built-in tools of the USB flash drive or usboot, flashboot, etc., to make the USB flash drive into a DOS bootable disk. At the same time, set the corresponding options in the computer's CMOS to see if the USB flash drive can boot into DOS. If it can, you can continue reading; if it cannot boot, you can try different modes, use other making tools, etc., and continue reading after it can boot.

In different boot modes, after the USB flash drive boots into DOS, it may be drive A or drive C on your computer.

Since the USB flash drive has a large capacity, various tools and WinPE can be stored on the USB flash drive.

When it is displayed as drive A, the usage method is similar to that of a floppy disk.

The usage of starting the img image file in the menu.lst file is as follows:

title GreenGhost (MAP-HOOK)
map --mem (fd0)/boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)


When it is displayed as drive C, the usage method is similar to that of a hard disk.

The usage of starting the img image file in the menu.lst file is as follows:

title GreenGhost (MAP-HOOK)
map --mem (hd0,0)/boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

In the above example, the menu.lst uses an absolute path to reference files, that is, (fd0)/boot/grub/gghost.img and (hd0,0)/boot/grub/gghost.img. This usage is no problem for a specific machine. But when the same USB flash drive is used on different machines, it may cause a problem. That is, different menu.lst files may be needed for different machines, otherwise the tool cannot be started normally. Then, is there any way to avoid this trouble? The answer is yes, that is, use "find --set-root" and a relative path to achieve. In this way, you don't have to worry about whether the USB flash drive is recognized as fd or hd.

For example, you can create a characteristic file in the root directory of the USB flash drive, such as myudisk.txt

In this way, to start the img image file on the USB flash drive, you can use the following method:

title GreenGhost (MAP-HOOK)
find --set-root /myudisk.txt
map --mem /boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

To boot WinPE on the USB flash drive, you can use:

title Micro Windows XPE (by LaoMaotao)
find --set-root /myudisk.txt
chainloader /ldrxpe

Refer to other examples, and by editing your menu.lst, you can give full play to the performance of the USB flash drive.


******************************************************************

5 Conclusion

This article only writes about some of the most basic applications of grub4dos. More functions of Grub4dos need you to try and explore.

I hope this article will help you use grub4dos faster.

I am looking forward to sharing your achievements.


Note: My network disk: http://lianjiang2004.ys168.com also provides the download of some grub-related files and materials.

Recommended forums:

Space Forum: http://bbs.znpc.net
China DOS Union Forum: http://www.cn-dos.net/forum/
Wuyou Boot Forum: http://bbs.wuyou.com

******************************************************************

6 Acknowledgments

The completion of this article refers to and quotes from many materials, and many of them can no longer find the original source. After the first draft was completed, many netizens pointed out the shortcomings and put forward modification suggestions, and also received the support and encouragement of the software developers. Thanks are extended here.

lianjiang 2007.03.13 First Draft
2007.03.13 First Revision
2007.03.14 Second Revision

[ Last edited by lianjiang2004 on 2007-3-29 at 09:01 PM ]
Recent Ratings for This Post ( 4 in total) Click for details
RaterScoreTime
electronixtar +8 2007-03-14 02:27
vkill +8 2007-03-14 02:30
NaturalJ0 +7 2007-03-27 21:56
xing7749 +8 2007-03-28 10:25
Windows 一键还原
http://www.yjhy.com
Floor 2 Posted 2007-03-14 02:25 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Not bad, sofa, top

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 3 Posted 2007-03-14 02:30 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Good post
Floor 4 Posted 2007-03-14 09:17 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Add the "2. Applications on the CD" section
Windows 一键还原
http://www.yjhy.com
Floor 5 Posted 2007-03-14 10:15 ·  中国 江苏 扬州 联通
初级用户
Credits 118
Posts 9
Joined 2004-08-22 00:00
21-year member
UID 30542
Gender Male
Status Offline
Study hard. . .
Floor 6 Posted 2007-03-15 04:36 ·  中国 河南 新乡 联通
等待验证用户
★★★
Credits 640
Posts 314
Joined 2006-08-13 17:20
19-year member
UID 60432
Gender Male
Status Offline
Floor 7 Posted 2007-03-15 09:08 ·  中国 吉林 长春 联通
初级用户
Credits 46
Posts 24
Joined 2006-12-13 23:06
19-year member
UID 73425
Gender Male
Status Offline
Give it a boost
Well written
Floor 8 Posted 2007-03-15 09:36 ·  中国 河北 邯郸 联通
中级用户
★★
Credits 223
Posts 59
Joined 2005-05-23 00:00
21-year member
UID 39002
Gender Male
Status Offline
Study, study, thanks
Floor 9 Posted 2007-03-15 23:16 ·  中国 河南 新乡 联通
等待验证用户
★★★
Credits 640
Posts 314
Joined 2006-08-13 17:20
19-year member
UID 60432
Gender Male
Status Offline
Floor 10 Posted 2007-03-19 03:18 ·  中国 河南 商丘 永城市 联通
初级用户
Credits 154
Posts 22
Joined 2004-05-30 00:00
22-year member
UID 25621
Gender Male
Status Offline
Must it be placed under the boot\grub directory? Can it be changed? For example, bootdir\airendos??
Floor 11 Posted 2007-03-19 04:53 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Originally posted by oumiga at 2007-3-19 03:18:
Must it be placed in the boot\grub directory?
Can it be changed? For example, bootdir\airendos??

It's not said to be necessary. You should know it by carefully reading the whole text.

1, Yes, place menu.lst in the root directory and specify the file path in menu.lst. There should be examples in the text.
For example, if the xly.img file is saved to C:\boot, then the menu.lst file should be changed accordingly:
map (hd0,0)/boot/xly.img (fd0)
Windows 一键还原
http://www.yjhy.com
Floor 12 Posted 2007-03-23 12:34 ·  中国 新疆 乌鲁木齐 电信
新手上路
Credits 6
Posts 3
Joined 2007-03-23 11:54
19-year member
UID 82664
Gender Male
Status Offline
Thank you, LZ! Learning and studying.
Floor 13 Posted 2007-03-27 21:57 ·  中国 江苏 苏州 联通
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
Well written! Back then, I spent several days figuring out how to use this, which was really time-consuming. It would have been great if there was this article earlier. ^_^
Floor 14 Posted 2007-03-28 10:26 ·  中国 北京 电信
高级用户
★★★
文盲
Credits 833
Posts 349
Joined 2004-01-26 00:00
22-year member
UID 16118
Gender Male
Status Offline
That's great, thank you, the poster
Floor 15 Posted 2007-03-28 12:06 ·  中国 江苏 苏州 电信
中级用户
★★
我是DOS学者
Credits 367
Posts 180
Joined 2006-05-14 10:53
20-year member
UID 55507
Gender Male
From 重庆
Status Offline
Why not make a CHM file for everyone to download and view? That would be better~~~
Forum Jump: