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-06-25 12:55
中国DOS联盟论坛 » GRUB4DOS、SYSLINUX及其它启动管理软件讨论专区 » A Beginner's Tutorial on grub4dos DigestIII StickyII View 187,771 Replies 140
Floor 106 Posted 2008-12-04 11:00 ·  中国 河北 廊坊 联通
新手上路
Credits 2
Posts 1
Joined 2008-12-03 20:02
17-year member
UID 132803
Gender Male
From 廊坊
Status Offline
Where is the picture???????
Floor 107 Posted 2008-12-13 23:52 ·  中国 广东 电信
新手上路
Credits 2
Posts 1
Joined 2008-12-11 21:21
17-year member
UID 133586
Gender Male
From 江西九江
Status Offline
Thanks!
Floor 108 Posted 2008-12-16 02:17 ·  中国 陕西 宝鸡 电信
新手上路
Credits 4
Posts 3
Joined 2008-11-25 10:59
17-year member
UID 132037
Gender Male
Status Offline
Got it, thanks to the landlord.
Floor 109 Posted 2008-12-17 13:18 ·  中国 四川 眉山 电信
新手上路
Credits 4
Posts 2
Joined 2008-12-16 21:48
17-year member
UID 134087
Gender Male
Status Offline
Print it out first and then read it slowly.

[ Last edited by a102135 on 2008-12-17 at 13:19 ]
Floor 110 Posted 2008-12-17 13:18 ·  中国 四川 眉山 电信
新手上路
Credits 4
Posts 2
Joined 2008-12-16 21:48
17-year member
UID 134087
Gender Male
Status Offline
Finally found a place to study! I've always wanted to learn knowledge in this area!

[ Last edited by a102135 on 2008-12-17 at 13:20 ]
Floor 111 Posted 2008-12-20 20:02 ·  中国 江苏 苏州 电信
新手上路
Credits 14
Posts 6
Joined 2007-08-15 12:24
18-year member
UID 95177
Gender Male
Status Offline
Getting started...
Floor 112 Posted 2009-01-18 10:19 ·  中国 安徽 马鞍山 联通
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
GRUB4DOS Beginner's Tutorial

2009-01-18:

GRUB4DOS has entered the countdown to the release of the final official version, so the beginner's tutorial is updated for the last time.
This tutorial will not be updated in the future.

New Content:

Advanced Section:
3.3b Automatically Rename grldr with Batch (Applicable to the Latest Version of grldr) NEW!
3.6 Method and Application of Passing Parameters Using dd Command NEW!

Appendix:
4.07 Introduction to GRUB2 Usage by bean NEW!
4.08 Advanced GRUB2 Tutorial by bean NEW!
4.09 Advanced Tutorial on gfxmenu Customization (New Customizable Menu) by bean NEW!

CHM Graphic Version Download:
http://gghost.qupan.com/1557049.html
http://lianjiang2007.ys168.com
http://lianjiang2004.ys168.com
Windows 一键还原
http://www.yjhy.com
Floor 113 Posted 2009-01-19 22:39 ·  中国 广东 深圳 盐田区 电信
初级用户
★★
Credits 187
Posts 87
Joined 2007-10-23 16:04
18-year member
UID 100558
Gender Male
Status Offline
This tutorial is of great use for us novices. Thanks, brother lianjiang2004!
Floor 114 Posted 2009-03-08 04:25 ·  中国 甘肃 兰州 电信
新手上路
Credits 2
Posts 1
Joined 2009-03-02 09:18
17-year member
UID 140361
Gender Male
Status Offline
The beginner's tutorial on grub4dos by lianjiang2004 is very useful for beginners, helping us avoid many detours and gain a deeper understanding of grub4dos. As a beginner, I have sorted out lianjiang2004's grub4dos beginner's tutorial - entry level according to my own understanding, which may be useful for newbies just getting in touch with grub4dos to quickly understand. Any errors are welcome for correction by experts.

grub4dos Beginner's Tutorial - Basic Level

History of grub4dos: GRUB for DOS (abbreviated as GRUB4DOS) is a secondary development version based on GNU GRUB. A big difference from the official GNU GRUB is the diversity of startup methods.

  grub4dos is a multi-boot guide management tool, which can be used to activate many operating systems such as Linux, BSD, OS/2, BeOS, Windows 95/98/NT, etc. All things are integrated in two files: grldr and grub.exe (GRUB is a boot program independent of the operating system, and menu.lst cooperates with it to achieve loading). In addition, in order to be compatible with the startup of Vista (Vista cannot load a boot file exceeding 64K), grub4dos has an additional grldr.mbr. grldr.mbr is equivalent to the boot sector of grub4dos, similar to bootsect.dos used when booting DOS under NT. Its main function is to search for the grldr file in the root directory of the local hard disk, floppy disk, and USB flash drive and load it. Any boot software that supports loading the boot sector can boot into grub4dos by loading grldr.mbr.

I. Obtaining grub4dos
Download grub4dos (http://nufans.net/grub4doshttp://grub4dos.nufans.nethttp://download.gna.org/grub4doshttp://grub4dos.sourceforge.net/grub4doshttp://sites.google.com/site/grubdos), and you can use it after decompression. The core files are as follows: grldr (for VISTA system, also need grldr.mbr) and grub.exe, and menu.lst (this is a sample). If you need Chinese support, use the files in the chinese subdirectory.

II. Common loading methods of GRUB4DOS
1. Load through boot.ini under NT: The partition type supports FAT (12/16/32), NTFS, EXT (2/3). Copy the grldr file to c:\, modify the c:\boot.ini file, add a line at the end of boot.ini: c:\grldr="Start GRUB4DOS" and set the timeout value in boot.ini to be greater than 0. The grldr does not have to be placed in the root directory. Their final purpose is to search for the grldr file in the root directory of each partition and load the first found grldr.
Another way is to rename grldr to ntldr to replace NT's ntldr (bootmgr of Vista), which is to directly load grldr through the boot sector of NT/Vista.
Enter grub4dos through the boot menu of Windows VISTA/Window 7, and use a batch file to automatically load grub4dos into the Vista startup item (loading grub4dos into the Vista startup item is relatively safer than loading into the MBR). See the appendix: Batch file to load into the VISTA startup item.
Note: The advantage of this method is that there is no need to modify the MBR

2. Load through grub.exe
grub.exe is a three-in-one program,
As a real-mode DOS program, it is directly loaded from a pure DOS environment. Boot to the DOS environment (preferably a pure DOS environment), then run grub.exe under DOS or in AUTOEXEC.BAT to enter grub4dos.
As a DOS setup driver, load it from DOS's config.sys in any way such as device=grub.exe, install=grub.exe, shell=grub.exe.
Load in the Linux kernel format using the kernel method (any program that supports loading the Linux kernel can use this method, for example: Linux, syslinux series, GNU GRUB, lilo).
Use in Linux:
# kexec -l grub.exe
# kexec -e
Use in syslinux, syslinux.cfg:
kernel grub.exe
Use in GNU GRUB:
kernel ((hd0,x)/)/PATH/grub.exe
Use in lilo: Use in lilo.conf:
image=/boot/grub.exe
The configuration file menu.lst can be saved in the directory where the grub file is located or other specified paths (can also be placed in the root directory of other partitions or other specified directories).
Note: The advantage of this method is that there is no need to modify the MBR; GRUB4DOS can be started in scripts or other DOS programs as needed

3. Load grub through MBR (boot directly into it)
Use bootlace (run in DOS/Win9x/linux environment), grubinst, grubinst_gui (run in 2000/xp/2003/vista environment) to install the boot code of GRUB4DOS into the MBR of the hard disk (or the master boot record of the hard disk image file), or install it into the boot sector of a floppy disk or floppy disk image. The MBR boot code does not point to a certain partition fixedly, but searches all partitions, finds and loads grldr. As long as there is a copy of grldr on a certain partition, it can be started. And when installing, the original Microsoft MBR can be backed up. If grldr is not found during startup, the backed-up MBR will be automatically loaded to start. After installing the boot code of grub4dos into the MBR, copy the grldr file to the root directory of a certain partition. If the boot code of grub4dos is installed into the boot sector of a partition, the grldr file must be placed in the root directory of that partition (the grldr file has a built-in menu, which can be edited with a built-in menu editor and does not depend on menu.lst).
When the computer starts, press the hot key (the default is the space bar, which can be customized) to start grub.
Example: Install the GRLDR code into the master boot record under DOS: bootlace.com 0x80
Example: Install the GRLDR code into a floppy disk under DOS: bootlace.com --floppy --chs 0x00
Example: Install the GRLDR code into a floppy disk image under DOS: bootlace.com --floppy --chs floppy.img
Example: Install the GRLDR code into the master boot record of the Windows XP system disk:
bootlace --force-backup-mbr --boot-prevmbr-first --time-out=3 --hot-key=0x3920 --mbr-disable-floppy 0x80 means that when installing the GRLDR code into the MBR, the original MBR is backed up (--force-backup-mbr), the original MBR is started by default, that is, the original Windows XP system is started (--boot-prevmbr-first), wait for 3 seconds (--time-out=3), the hot key is the space bar (--hot-key=0x3920), and the GRLDR on the floppy disk is not searched (--mbr-disable-floppy). That is, wait for 3 seconds when starting. If the hot key is not pressed within 3 seconds, Windows XP is started; if the hot key is pressed within 3 seconds, grub4dos is started. For other parameters of bootlace and the usage of custom hot keys, refer to the readme.txt file.
Note: The advantage of this method is that it does not depend on the operating system; it can automatically search for the grldr file in each partition of the hard disk.

After starting GRUB4DOS, start other operating systems through it:
Start the Linux kernel, method: kernel (DEVICE)/PATH/vmlinuz
Start the MS-DOS kernel, method: chainloader (DEVICE)/io.sys
Start the FreeDOS kernel, method: chainloader (DEVICE)/kernel.sys
Start the NTLDR of Windows NT, method: chainloader (DEVICE)/ntldr
Start the CMLDR of the recovery console of Windows NT, method: chainloader (DEVICE)/cmldr. Note: A similar method can be used to start setupldr.bin of NT
Start DOS/Windows9x from a disk image file through disk emulation (memory disk)
Start from the CD-ROM

III. Basic concepts and descriptions
1. Naming method of devices and partitions
In GRUB, hard disk devices are named in the following way:
(hdm) m is the serial number of the hard disk. The serial number 0 corresponds to the first hard disk of the BIOS.
(hdm,n) n is the serial number of the partition in hard disk m (that is, the partition on the hard disk). There are up to 4 primary partitions, and their serial numbers are 0-3, and the serial number of the extended partition starts from 4.
Example: (hd0,0) The first primary partition on the first hard disk, that is, the C drive. (hd0,4) The first extended partition on the first hard disk. That is, the D drive.
(0x80,0) is represented by the corresponding BIOS device number. The device number of the first hard disk device is 0x80.

In GRUB, floppy disk devices are named in the following way:
(fdm) m is the serial number of the floppy disk. The serial number 0 corresponds to the first floppy disk of the BIOS. The floppy disk device can also be followed by the serial number of the partition or sub-partition.
GRUB also has some other devices, such as (cd) is the CD-ROM device, and (nd) is the network device.

2. File name and file path
The file name of GRUB is based on the device name plus the file path
(hd0,0)/boot/grub/aa.img, the absolute path is (hd0,0)/boot/grub/ , the relative path is /boot/grub/ . Note: The directory separator is /, not \ commonly used under Windows/DOS. Example: (fd0)/boot/aa.img means the aa.img file in the boot directory on the floppy disk 0 with a relative path.
Data can also be specified by the sector offset and number
(hd0,0)0+100,200+1,300+300 means in the first primary partition on hard disk 0, 100 sectors starting from sector 0, then 1 sector starting from sector 200, and finally 300 sectors starting from sector 300. When the offset is zero, it can be omitted. Therefore, (hd0,0)+1 means 1 sector starting from sector 0 in the first primary partition on hard disk 0, that is, the first sector of the partition.
The file on the root device can omit the device name. For example: The root+1 command is equivalent to root(hd0,0)+1.
The meaning of the file name used in the map (hd0,0)+1 command is different from the above. In the map command, +1 does not mean the first sector of the first primary partition on hard disk 0, but the entire partition of the first primary partition on hard disk 0.

IV. Usage and description of main commands For more command usage, see the appendix Grub Command Index

chainloader - Load the content of the boot sector into memory. The parameter +1 means load the first sector of the partition into memory to start other operating systems. Note: Mainly used to boot the boot sector (MBR) of the corresponding device, such as the hard disk MBR, CD-ROM, floppy disk, primary partition boot sector, etc.
displaymem - Display the current memory usage, this information is based on the BIOS. This command is helpful to determine how much memory the system has before booting.
kernel - When using the direct loading method to boot the operating system, the kernel command specifies that the kernel is loaded from the GRUB root file system. The options option follows the kernel command and is passed to the kernel when the kernel is loaded.
root - Set the GRUB root partition to a specific device and partition, such as (hd0,0). And mount this partition so that files can be read.
rootnoverify - Do the same thing as the root command, but do not mount the partition.
Both root and Rootnoverify can be used to specify the root device. root tests whether the file system of the partition can be recognized before setting the root device, while rootnoverify omits this test.
boot – Start the operating system or file that has been specified and loaded previously. Before using this command, the system kernel or boot sector, boot file must be loaded into memory using kernel or chainloader. This
Floor 115 Posted 2009-05-16 06:03 ·  中国 广东 揭阳 联通
新手上路
Credits 8
Posts 4
Joined 2008-03-30 13:39
18-year member
UID 114438
Gender Male
Status Offline
Been looking for it all the time, and it's here originally.
Floor 116 Posted 2009-05-21 19:35 ·  中国 江西 上饶 电信
初级用户
Credits 31
Posts 24
Joined 2009-04-04 10:37
17-year member
UID 142105
Gender Male
Status Offline
Thanks to the thread starter
Floor 117 Posted 2009-05-23 03:51 ·  中国 湖北 武汉 电信
新手上路
Credits 2
Posts 1
Joined 2009-05-21 23:24
17-year member
UID 145660
Gender Male
Status Offline
Thank you so much, sincerely thank you
Floor 118 Posted 2009-06-12 05:04 ·  中国 辽宁 营口 中移铁通
初级用户
★★
DOS之迷
Credits 174
Posts 81
Joined 2007-11-07 21:13
18-year member
UID 102004
Gender Male
Status Offline
Not bad. Thanks for your hard work.
愛意之无尽@灵犀!
QQ:71216716 E_mail:l.h.r.@163.com
Floor 119 Posted 2009-08-31 00:30 ·  中国 广东 广州 天河区 电信
新手上路
Credits 4
Posts 2
Joined 2006-10-16 05:59
19-year member
UID 65934
Gender Male
Status Offline
Three years, it's rare for the LZ to persevere, thanks
Floor 120 Posted 2009-09-02 09:48 ·  中国 辽宁 大连 联通数据中心
新手上路
Credits 2
Posts 1
Joined 2009-05-22 03:46
17-year member
UID 145683
Gender Male
Status Offline
Finally, I have a little bit of understanding. It seems that the road I need to learn is still very long.
Forum Jump: