GRUB for DOS tutorial
1. Introduction
1.1 What is GRUB for DOS
1.2 Difference between GRUB for DOS and GNU GRUB
2. Installation
2.1 Install GRUB for DOS boot code to MBR
2.2 Install GRUB for DOS boot code to partition boot sector
2.3 Starting GRUB for DOS from DOS
2.4 Starting GRUB for DOS from Linux
2.5 Booting GRUB for DOS via the Windows NT/2000/XP/2003 boot manager
2.6 Booting GRUB for DOS via the Windows Vista boot manager
2.7 Loading GRUB for DOS using other boot loader
3. Booting DOS/Windows 9X/Windows NT startup files
4. Disk emulation
4.1 Direct mapping
4.2 Indirect mapping
4.3 Auto MBR creation
4.4 memdisk
5. CDROM related subjects
5.1 Using ATAPI CDROM in GRUB for DOS
5.2 Create a bootable CDROM
5.3 Load GRUB for DOS from BCDW
1. Introduction
1.1 What is GRUB for DOS
GRUB for DOS is an universal boot loader based on GNU GRUB. It can boot off DOS/LINUX, or via Windows boot manager/syslinux/lilo, or from MBR/CD. It also has builtin BIOS disk emulation, ATAPI CDROM driver, etc.
1.2 Difference between GRUB for DOS and GNU GRUB
First of all, GRUB for DOS has a flexible boot loader. Unlike GNU GRUB which relies on three stages of files to boot, GRUB for DOS uses a much better solution. The main function of GRUB is placed in a single file grldr, while the boot loader is placed in another file grldr.mbr, which can be installed to MBR or partition boot sector. At startup, boot code in grldr.mbr will dynamically scan the root directory of every local partition for grldr, and load the first one found. Using this scheme, the location of boot file is no longer fixed, users can move it across partition boundary without causing booting problems.
Secondly, GRUB for DOS can be loaded in multiple ways. GRUB for DOS runtime image comes in two forms. One is grldr, which can be loaded by MBR/partition boot sector and the Windows NT/2000/XP/2003/Vista boot manager. It can also act as the eltorito boot file for bootable CDROM. The other is grub.exe, which is a hybrid executable that can be launched from linux console and DOS prompt.
Thirdly, GRUB for DOS extends the function of GNU GRUB. The most significant enhancement is the map command. In GRUB for DOS, the map command can be used to create virtual harddisks and floppies from image files. These virtual devices can be accessed even after DOS starts.
There are other useful features of GRUB for DOS which are not present in GNU GRUB, such as ATAPI CDROM driver, Chinese support, and so on.
2. Installation
There are many ways to install GRUB for DOS. Some of them requires modifying MBR or partition boot sector, while others requires changing system startup configuration files.
2.1 Install GRUB for DOS boot code to MBR
You can use bootlace.com or grubinst.exe to install GRUB for DOS boot code to MBR:
bootlace.com can be used in DOS, Windows 95/98/Me and Linux. Examples:
Install GRUB for DOS boot code to the MBR of first hard drive under DOS, Windows 95/98/Me:
bootlace 0x80
Install GRUB for DOS boot code to the MBR of IDE channel 0, primary drive under Linux:
bootlace /dev/hda
Install GRUB for DOS boot code to the MBR of hard drive image file aa.dsk:
bootlace aa.dsk
grubinst.exe can be used in Linux, FreeBSD and Windows NT family OSs (Windows NT/2000/XP/2003/Vista). Examples:
Install GRUB for DOS boot code to the MBR of first hard drive under Windows NT family OSs:
grubinst (hd0)
Install GRUB for DOS boot code to the MBR of IDE channel 0, primary drive under Linux/FreeBSD:
grubinst "(hd0)"
You can also use device names:
grubinst /dev/hda (Linux)
grubinst /dev/ad0 (FreeBSD)
Install GRUB for DOS boot code to the MBR of hard drive image file aa.dsk:
grubinst aa.dsk
There are many options you can use with bootlace and grubinst, use the -h option to display help message.
After installing the boot code, you need to copy grldr and menu.lst to the root directory of any FAT16/FAT32/NTFS/EXT2 partition.
2.2 Install GRUB for DOS boot code to partition boot sector
You can use grubinst to install GRUB for DOS boot code to partition boot sector. Examples:
Install GRUB for DOS boot code to the first primary partition of the first hard drive:
grubinst (hd0,0)
or
grubinst --install-partition=0 (hd0)
or
grubinst -p=0 (hd0)
Install GRUB for DOS boot code to the first primary partition of the hard drive image file aa.dsk:
grubinst --install-partition=0 aa.dsk
or
grubinst -p=0 aa.dsk
Just as in GRUB, extended partition starts with (hd0,4).
After installing the boot code, you need to copy grldr and menu.lst to the partition which you install the boot code on.
2.3 Starting GRUB for DOS from DOS
You can use load GRUB for DOS in config.sys using one of the following lines:
DEVICE=GRUB.EXE
INSTALL=GRUB.EXE
SHELL=GRUB.EXE
grub.exe can also be launched from DOS prompt or batch file such as AUTOEXEC.BAT.
2.4 Starting GRUB for DOS from Linux
First, you need to apply the kexec patch to the Linux kernel.
Then, you can use the following commands to launch GRUB for DOS from linux:
kexec -l grub.exe
kexec -e
2.5 Booting GRUB for DOS via the Windows NT/2000/XP/2003 boot manager
Add the following line at the end of boot.ini (this file is hidden):
C:\grldr="Start GRUB4DOS"
Then copy grldr to C:\, and create the GRUB4DOS configuration file at C:\menu.lst.
Next time you start windows, there is a new option "Start GRUB4DOS" which can be used to start GRUB for DOS.
2.6 Booting GRUB for DOS via the Windows Vista boot manager
Use bcdedit to configure the startup menu:
bcdedit /create /d "Start GRUB4DOS" /application bootsector
bcdedit /set {id} device boot
bcdedit /set {id} path \grldr.mbr
bcdedit /displayorder {id} /addlast
Then copy grldr.mbr to C:\, grldr and menu.lst to the root directory of any FAT16/FAT32/NTFS/EXT2 partition.
grldr.mbr can also be used to start GRUB for DOS in Windows NT/2000/XP/2003 (in fact, grldr.mbr is basicly the first 16 sectors of grldr). To use grldr.mbr as the boot file, use the following line in boot.ini:
C:\grldr.mbr="Start GRUB4DOS"
As in Windows Vista, you need to copy grldr and menu.lst to the root directory of any FAT16/FAT32/NTFS/EXT2 partition.
2.7 Loading GRUB for DOS using other boot loader
grub.exe can be loaded as a linux kernel.
Load GRUB for DOS using GRUB or another copy of GRUB for DOS, add the following section to menu.lst:
title Load GRUB4DOS
kernel /grub.exe
Load GRUB for DOS using syslinux, add the following section to syslinux.cfg:
label GRUB4DOS
KERNEL grub.exe
3. Booting DOS/Windows 9X/Windows NT startup files
In GRUB for DOS, you can load the DOS/Windows 9X/Windows NT startup files directly.
DOS, Windows 95/98/Me:
title Load io.sys
root (hd0,0)
chainloader (hd0,0)/io.sys
Windows NT/2000/XP/2003:
title Load ntldr
root (hd0,0)
chainloader (hd0,0)/ntldr
Windows Vista:
title Load bootmgr
root (hd0,0)
chainloader (hd0,0)/bootmgr
Quoted from http://www.znpc.net/.....;extra=page=1