Grub For Dos Concise User Manual for Linux Users 


Focus on how to use the latest (v0.4.2) grub4dos with SYSLINUX. No historic, or DOS/Windows specific information included.


GRUB [--bypass] [--time-out=T] [--hot-key=K] [--config-file=FILE]

The FILE, for example, can be (hd0,0)/menu.lst

If no options present, GRUB.EXE simply uses


as the configure file, if it exists.

The partition (hd0,0) can be of a Windows partition or a Linux partition, or any other partition type supported by GRUB.


The FILE can be the contents of a menu. Use semi-colon to delimitate the embedded commands here in FILE. The FILE can be enclosed with a pair of double-quotes. For example:

GRUB --config-file="root (hd0,0);chainloader +1"

This command will boot the system in (hd0,0).

Another example, to reboot the machine:

GRUB --config-file="reboot"

One more example, to halt the machine:

GRUB --config-file="halt"

if —bypass is specified, GRUB will exit to DOS when timeout reached.

The option `—time-out=T' specifies the timeout value in seconds. T defaults to 5 if —bypass is specified and defaults to 0 if —bypass is not specified.

The default hot key value is 0x3920(for space bar). If this key is pressed, GRUB will boot normally. If another key is pressed, GRUB will terminate immediately and return back to DOS. See "int 16 keyboard scan codes" below.

Each option can be specified only once at most.


You can boot grub using a linux loader KEXEC, LILO, SYSLINUX or another GRUB. (GRUB4LIN has merged into GRUB.EXE)

To boot GRUB off Linux, use this pair of commands:

kexec -l grub.exe
kexec -e

To boot GRUB via GRUB, use commands like the following:

kernel (hd0,0)/grub.exe

To boot GRUB via LILO, use these lines in lilo.conf:


To boot GRUB via SYSLINUX, use these lines in syslinux.cfg:

label grub.exe
        kernel grub.exe

Using Memdrives 



# boot into a floppy image
map --mem (hd0,0)/floppy.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1

Because the image will be copied to a memory area, the image itself can be non-contiguous and even gzipped.

Another Example:

map --mem=-2880 (hd0,0)/floppy.img (fd0)

This memdrive (fd0) will occupy at least 1440 KB of memory. This is useful when the size of a 1.44M-floppy image is less than 1440 KB.

One more example:

map --mem --read-only (hd0,0)/hd.img (hd1)

This memdrive is a hard drive, and read-only. That means you will not be able to write data to the memdrive (hd1).


the hd.img can be created by 'mkdiskimage' from the syslinux package.

You can use many memdrives and many ordinary virtual emulated disk-based drives at the same time.

If the BIOS does not support int15/EAX=e820h, you will not be able to use any memdrives.

Memdrive emulation 

For memdrive emulation, a single-partition image can be used instead of a whole-harddrive image. Example:

map --mem (hd0,7)/win98.img (hd0)
map --hook
chainloader (hd0)+1
rootnoverify (hd0)
map --harddrives=1

Here win98.img is a partition image without the leading MBR and partition table in it. Surely GRUB for DOS will build an MBR and partition table for the memdrive (hd0).

Disk emulation 

Floppies/harddisks of any size can be emulated with GRUB for DOS.

Image file must be contiguous, or else GRUB for DOS will refuse it.

The `blocklist' command can list fragments or pieces of a file.

Type "help map" at the GRUB prompt to get a brief description of the command.

The form

map ... (fd?)

is a floppy emulation, and the form

map ... (hd?)

is a hard disk emulation.

When —mem is used, it seems rather safe even after entering Windows. Win98 can operate the memdrive normally.

Windows NT/2000/XP does not recognize the emulated drives no matter whether the —mem option is present.

Disk emulation examples 

  1. Emulates HD partition C: as floppy drive A: and boot win98 from C:

    map --read-only (hd0,0)+1 (fd0)
    chainloader (hd0,0)+1
    rootnoverify (hd0)

    In the above example, (hd0,0) is drive C: with win98 on it. After win98 boot complete, you will find that A: contains all files of C:, and if you delete files in A:, the files in C: will also disappear.

    At the map command line, the notation (hdm,n)+1 is interpreted to represent the whole partition (hdm,n), not just the first sector of the partition.

  2. Emulates HD partition C: as floppy drive A: and boot win98 from A:

    map --read-only (hd0,0)+1 (fd0)
    map --hook
    chainloader (fd0)+1
    rootnoverify (fd0)
    map --floppies=1

    After the "map —hook" command, the emulation takes effect instantly even in the GRUB command line.

    Note that the (fd0) in "chainloader (fd0)+1" is the emulated virtual floppy A:, not the real floppy diskette(because map is hooked now).

  3. Emulates an image file as floppy drive A: and boot win98 from C:

    map --read-only (hd0,0)/floppy.img (fd0)
    chainloader (hd0,0)+1
    rootnoverify (hd0)
    map --floppies=1
    map --harddrives=1
  4. Emulates an HD partition as the first hard disk and boot DOS from it:

    map --read-only (hd2,6)+1 (hd0)
    map --hook
    chainloader (hd0,0)+1
    rootnoverify (hd0)
    map --harddrives=1

    In this example, (hd2,6)+1 represents an extended logical DOS partition of the third BIOS hard disk (hd2).

    If a DOS partition is used to emulate a hard disk, GRUB for DOS will first try to locate the partition table, usually 63 sectors ahead of the DOS partition. GRUB for DOS will refuse the emulation if the partition table is not there.

  5. Emulates an image file as the first hard disk and boot DOS from it:

    map --read-only (hd0,0)/harddisk.img (hd0)
    chainloader --load-length=512 (hd0,0)/harddisk.img
    rootnoverify (hd0)
    map --harddrives=1

    If an image file is used to emulate a hard disk, the image file must contain an MBR. In other word, the first sector of HARDDISK.IMG must contain the partition table of the emulated virtual hard disk.


Counters for floppies and harddrives in the BIOS Data Area remain unchanged during the mapping. You should manually set them to proper values with `map —floppies=' and/or `map —harddrives=', especially, e.g., when there is no real floppy drive attached to the mother board. If not doing so, DOS might fail to start.

`map —status' can report the values. Note also that `map —floppies=' and `map —harddrives=' can be used independently without the appearance of mappings.

0.4.2 has introduced a new variable, memdisk_raw, to simulate the memdisk-like raw mode. If the BIOS has no int15/87h, or if it has buggy int15/87h support, you should set this variable before any memdrives are used. Here is an example:

map --memdisk-raw=1
map --mem (hd0,0)/floppy.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

If you encountered a memdrive failure without using map —memdisk-raw=1, you should have a try with `map —memdisk-raw=1'.

If you `map —memdisk-raw=0' later, you should afterwards do a `map —unhook'(and followed by a `map —hook' if needed).

memdisk_raw defaults to 1. You should `map —memdisk-raw=0' if you want to use int15/87h to access memdrives.

bootable images 

By using kexec, we can easily boot into DOS/Win9x from a running Linux system.

If WIN98.IMG is a bootable hard-disk image, do as follows:

kexec -l grub.exe --initrd=WIN98.IMG --command-line="--config-file=map (rd) (hd0); map --hook; chainloader (hd0)+1; rootnoverify (hd0)"
kexec -e

If DOS.IMG is a bootable floppy image, do this way:

kexec -l grub.exe --initrd=DOS.IMG --command-line="--config-file=map (rd) (fd0); map --hook; chainloader (fd0)+1; rootnoverify (fd0)"
kexec -e

Note that in this manner, we can boot DOS/Win9x without using a real DOS/Win9x disk. We need no FAT partition but an image file.

We have noticed that Linux itself can act as a big boot manager by using kexec and grub.exe. This may be convenient to developers who write installation or bootstrap or initialization programs.

Certainly, grub.exe and the bootable disk image can also be loaded by a running GRUB or LILO or syslinux. Examples:

  1. Loaded by GRUB:

    kernel (hd0,0)/grub.exe --config-file="map (rd) (fd0); map --hook; chainloader (fd0)+1; rootnoverify (fd0)"
    initrd (hd0,0)/DOS.IMG
  2. Loaded by LILO:

            append="--config-file=map (rd) (fd0); map --hook; chainloader (fd0)+1; rootnoverify (fd0)"
  3. Loaded by SYSLINUX:

    label grub.exe
            kernel grub.exe
            append initrd=DOS.IMG --config-file="map (rd) (fd0); map --hook; chainloader (fd0)+1; rootnoverify (fd0)"

If the above `map (rd) (…)' failed, you may use `map (rd)+1 (…)' instead and try again.

more on map options 

Along with 0.4.2 final, there are two new options for the map command. They are —safe-mbr-hook=SMH and —int13-scheme=SCH. Both are related with disk emulation for use(as smoothly as possible) in the Win9x environment.

SMH can take either of the two values 0 and 1. By default, SMH is 1. If you encountered problems of disk emulation under Win9x, you may insert a line of

map --safe-mbr-hook=0

before the `boot' command and try again.

Also SCH may take either 0 or 1 at present. By default, SCH is 1. If you encountered disk emulation problems under Win9x, you may insert a line of

map --int13-scheme=0

before the `boot' command and try again.

Note by the way. Like —safe-mbr-hook and —int13-scheme, the MAP command has a few other options that are used for setting global variables. They are here:

map --floppies=M

M can be 0, 1, or 2. MAP will set a proper value at 0040:0010 by using M.

map --harddrives=N

N can be between 0 and 127(inclusive). MAP will set 0040:0075 to N.

map --memdisk-raw=RAW

RAW default to 1. If RAW=0, `int15/ah=87h' will be used to access memdrives.

map --ram-drive=RD

RD default to 0x7F which is a floppy. If the RAM DRIVE is a hard drive image (with partition table in the first sector), you should set RD >= 0x80 and RD < 0xFF.

map --rd-base=ADDR
map --rd-size=SIZE

ADDR specifies the physical base address of the ramdisk image. SIZE specifies the size in bytes of the ramdisk image. ADDR default to 0. SIZE is also default to 0, but a size of 0 means 4GB, not a zero-long disk. The RAM DRIVE can be accessed in the GRUB environment using the (rd) device.

The enhanced cat command 

The cat command now has a few new options: —hex for hexdump, and —locate=STRING for string search in file.

Typical examples:

cat --hex (hd0)+1

It will display the MBR sector in hex form.

cat --hex (md)+2

It will display 1KB of your memory(in fact, it is the real-mode IDT table), also in hexdump form.

cat --hex (md)0x800+1

It will display 1 sector of your extended memory.

cat --hex (hd0,0)+1

It will display the first sector of partition (hd0,0). Usually this sector contains the boot record of an operating system.


You should unzip the package under Linux in this way:

unzip grub_for_dos-*.zip

then cd into the grub_for_dos-* dir and do a make.

documented on: 2007.01.20