Please refer to http://grub4dos.sourceforge.net/wiki/ for DOCs on GRUB4DOS.

Main project page:	https://gna.org/projects/grub4dos/

Download site:		http://download.gna.org/grub4dos/
Download site:		http://grub4dos.sourceforge.net/
Download site:		http://sarovar.org/projects/grub4dos/
Download site:		http://grub4dos.nufans.net/
Download site:		http://sites.google.com/site/grubdos/
Download site:		ftp://grub4dos.sarovar.org/pub/grub4dos/

Get the latest source code by using anonymous svn in this way:

	svn co svn://svn.gna.org/svn/grub4dos/trunk grub4dos

or in this way:

	svn co http://svn.gna.org/svn/grub4dos/trunk grub4dos

View the source code online with your web browser at:

	http://svn.gna.org/viewcvs/grub4dos/trunk/

GRUB4DOS mailing list:

	grub4dos-devel@gna.org

Subscription page:

	https://mail.gna.org/listinfo/grub4dos-devel/

Discussion forum(Official technical support site):

	http://www.boot-land.net/forums/index.php?showforum=66

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

Usage:
		GRUB [--bypass] [--time-out=T] [--hot-key=K] [--config-file=FILE]
		
		The FILE, for example, can be (hd0,0)/menu.lst
		
		In CONFIG.SYS, the line looks like:
		
			install=c:\some\where\grub.exe --config-file=FILE
		
		If no options present, GRUB.EXE simply uses
		
			(hd0,0)/menu.lst
		
		as the configure file, if it exists. (Notice! We finally
		changed the default file from (hd0,0)/boot/grub/menu.lst to
		(hd0,0)/menu.lst) (Changed 2006-12-23. See Update 3 below.)
		
		The partition (hd0,0) can be of a Windows partition or a Linux
		partition, or any other partition type supported by GRUB.

		Only GRUB-style filename is acceptable here for FILE. A DOS
		filename won't work(it is certain we should use GRUB-style
		filenames because DOS-filenames won't access a file in a
		Linux ext2 partition for example).(See Update 2 below)

		Update: 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:

			GRUB --config-file="reboot"

		This command will reboot the machine.

		One more example:

			GRUB --config-file="halt"

		This command will halt the machine.

		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.

		Update 2: DOS filenames have been supported(patched by John
		Cobb). If the beginning two characters of FILE are "#@", then
		the rest of FILE is taken as a DOS filename. Example:

			GRUB --config-file="#@c:\menu.lst"

		Only the beginning 4KB of the DOS file will be used. The file
		should be an uncompressed text file.

		Note: You may also use the `direct DOS file access' with the
		SHELL or INSTALL line in CONFIG.SYS, but should not use it
		with the DEVICE line. The DOS document said that a DOS device
		driver should not call the `open file' DOS call.

		Update 3(2006-12-23): By default, GRUB.EXE will locate its
		config file in the following order:

			(DOS file) .\menu.lst, the MENU.LST in the current dir.

			(DOS file) \menu.lst, the MENU.LST in the root dir of
						the current drive.
			(GRUB file) /menu.lst, the MENU.LST in the root dir of
						the boot device.

		The default boot device is still (hd0,0).


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

Update 2:	GRUB for Linux is also introduced along with 0.2.0. 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
			boot

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

			image=/boot/grub.exe
			label=grub.exe

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

			label grub.exe
				kernel grub.exe

		LOADLIN may encounter problems when loading grub.exe, because
		grub.exe requires some unchanged original BIOS interrupt
		vectors, but DOS has destroyed them, and loadlin does not
		recover them before it transfers control to grub.exe.
		
Update 3:	Beginning at version 0.4.0, GRUB for DOS supports memdrives.
		Example:

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

		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).

		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.

Update 4:	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
			boot

		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).

Update 5:	Now GRLDR can be used as a no-emulation-mode bootable CD-ROM
		boot image. Example for Linux users:

			mkdir iso_root
			cp grldr iso_root
			mkisofs -R -b grldr -no-emul-boot -boot-load-seg 0x1000 -o bootable.iso iso_root

		As an alternative, grldr can also be used the same way as
		stage2_eltorito. The -boot-info-table option is allowed but you
		can omit it:

			mkdir iso_root
			cp grldr iso_root
			mkisofs -R -b grldr -no-emul-boot -boot-load-size 4 -o grldr.iso iso_root

		Also note that the bootable.iso above must be created with the
		-boot-load-seg 0xHHHH option where HHHH is greater than or
		equal to 1000(hex). If HHHH < 1000(hex), QEMU will hang. This
		is a bug in QEMU. The grldr.iso can be created with or without
		-boot-load-seg 0xHHHH option.

		The menu.lst file should be placed in the root dir of the CD.

Update 6:	The Chinese special build is in the "chinese" subdirectory.
		(patched by Gandalf, 2005-06-27)

		The Chinese special build also has scdrom builtin.
		(update: scdrom has been dropped since 2006-07-20)

Update 7:	Added memory drive (md). Like (nd) for network drive and (cd)
		for CD-ROM drive, a new drive (md) is implemented for accessing
		the whole memory as a disk drive. (md) only works for systems
		with BIOS int15/EAX=E820h support.

		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.

Update 8:	Added ram drive (rd). The (md) device accesses the memory
		starting at physical address 0. But (rd) accesses memory
		starting at any base address. The base and length of the ram
		drive can be specified through the map command. "help map" for
		details. You can even specify the BIOS drive number used for
		the (rd) drive, e.g., map --ram-drive=0xf0. The default drive
		number for (rd) is 0x7F which is a floppy. If (rd) is a hard
		drive image, you should change the drive number to a value
		greater than or equal to 0x80(but should avoid using 0xffff,
		because 0xffff is for the (md) device).

		The notation (rd)+1 always represents the file which contains
		all the bytes stored in (rd).

Update 9:	Directly boot NTLDR of WinNT/2K/XP and IO.SYS of Win9x/ME and
		KERNEL.SYS of FreeDOS. Examples:

			chainloader --edx=0xPPYY (hd0,0)/ntldr
			boot

			chainloader --edx=0xYY (hd0,0)/io.sys
			boot

			chainloader --ebx=0xYY (hd0,0)/kernel.sys
			boot

		Hex YY specifies the boot drive number, and hex PP specifies
		the boot partition number of NTLDR. If the boot drive is
		floppy, PP should be the hex value ff, i.e., decimal 255.

		For KERNEL.SYS of FreeDOS, the --edx won't work,
		use --ebx please.

		The option --edx ( --ebx ) can be omitted if the file is in
		its normal place. But in some cases, those options are needed.

		If, e.g., the ntldr file is in an ext2 partition called
		(hd2,8) while you want it to think of the Windows partition
		(hd0,7) as the boot partition, then --edx is required:

			chainloader --edx=0x0780 (hd2,8)/ntldr

		For DOS kernels(i.e., IO.SYS and KERNEL.SYS), the boot
		partition number is meaningless, so you only need to specify
		the correct boot drive number YY(but specifying the boot
		partition number is harmless).

		The above PPYY can also be specified by using a root or
		rootnoverify command after the chainloader command. Examples:

			chainloader (hd2,6)/kernel.sys
			rootnoverify (hd0)	<-------- YY=80
			boot

			chainloader (hd0,0)/ntldr
			rootnoverify (hd0,5)	<-------- YY=80, PP=05
			boot

		Tip: CMLDR (the ComMand LoaDeR, which is used to load the
		Windows Fault Recovery Console) can be chainloaded as well
		as NTLDR.

		Bean has successfully decompressed and booted IO.SYS of WinME.
		Thanks for the great job!

Update 10:	isolinux.bin (version 3.73) can be chainloaded as with build
		2009-02-09.

			chainloader (cd)/isolinux.bin

		isolinux.bin must reside in a real or virtual cdrom.

Update 11:	stage2 of Grub Legacy can be chainloaded in this way:

			chainloader --force --load-segment=0 --load-offset=0x8000 --boot-cs=0 --boot-ip=0x8200 (...)/.../stage2

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

	There is no full documentation in English at present. Here are some
	examples showing the usage of disk emulation commands:

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)
		boot

	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
		boot

	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
		boot

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
		boot

	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
		boot

	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.

Note:	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)
		boot

	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).

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

--------------------------------------------------------
	
	Floppies/harddisks of any size can be emulated with GRUB for DOS 0.2.0.
	
	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 a HARD DISK emulation is used, better not start Windows for
	security reasons. Windows may even destroy all data and all information
	on all your real hard disks!!!!!!!!
	
	Update for --mem: 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.


******************************************************************************
***           Direct transition to DOS/Win9x from within Linux             ***
******************************************************************************

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
	boot

2. Loaded by LILO:

	image=/boot/grub.exe
		label=grub.exe
		initrd=/boot/DOS.IMG
		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)"

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

******************************************************************************
***                             Known BIOS bugs                            ***
******************************************************************************

1. Some newer Dell machines have no int13/AH=43h support. You may encounter
	failure when trying to write-access an emulated disk.

	Note: This bug is serious! The old "root+setup" installation method
	(in real mode grub environment) uses INT13 to write the first sector
	of stage2. It will fail for the buggy DELL machine when stage2 is
	accessed with LBA mode.

2. Some buggy BIOSes won't boot bootable.iso(See above).(qemu can boot it fine)

3. Some newer Dell machines violently destroyed the interrupt vectors for
	hardware IRQs and will hang the machine when running GRUB.EXE
	from DOS.

4. Reports say some BIOSes will function abnormally after GRUB.EXE is started
	by kexec of Linux. Some machines reportedly hang. Some others
	reportedly cannot access USB drives.


******************************************************************************
***                             Known Problems                             ***
******************************************************************************

1.	Running GRUB.EXE from a DOS box of Windows 9x/Me could hang the
	machine, especially for some systems with USB support. You may
	encounter the same problem when running GRUB.EXE through KEXEC under
	Linux.

Note:	You don't have to run GRUB.EXE from protected mode of Win9x, which
	could hang the machine; Instead, you usually want to run GRUB.EXE
	after you have done a "Restart the computer in MS-DOS mode", which
	is safe enough.

2.	The default chainloader action will keep A20 on. Some buggy DOS XMS
	memory managers could hang the machine. You may use the --disable-a20
	option in the chainloader line and try again. Anyway, you should avoid
	using those buggy memory managers.

3.	THTF BIOS L4S5M Ver 1.1a(dated 2002-1-10) has a buggy int15 which
	causes hang at the boot of a multi boot kernel(memdisk for example).

4.	A Chinese DOS system software, the TechWay SCS, will not work with
	newer versions of GRUB.EXE. In general, TSRs that take antitracking
	measures will not work with GRUB.EXE any more.


******************************************************************************
***                Command-line Length about GRUB.EXE                      ***
******************************************************************************

GRUB.EXE now can be started in CONFIG.SYS with the **DEVICE** command:

	DEVICE=grub.exe [--config-file="FILENAME_OR_COMMANDS"]

1. If GRUB.EXE is invoked with DEVICE command and FILENAME_OR_COMMANDS is a
collection of some GRUB commands separated by semi-colon, then the length of
FILENAME_OR_COMMANDS can be nearly 4KB ----Supprise? But true!  MS-DOS 7+
even allows a much longer line, but 4KB seems enough for our use of GRUB.EXE.
This is very useful when we want to embed a big menu into the command line.
Note that GRLDR hasn't yet supported any command-line arguments.

2. If GRUB.EXE is invoked with INSTALL command, the option length has a limit
of 80 characters(including the leading "--config-file=" part). An overflow may
hang up MS-DOS immediately.

3. If GRUB.EXE is invoked with SHELL command, the option length has a limit of
126 characters(including the leading "--config-file=" part). Overflow won't
hang up MS-DOS, but the line will be cut short. This limit is the same as that
in the console-DOS-prompt or in a BAT file.

4. The DOS editor EDIT does not allow to create a line of 4KB long. So use
another editor, for example, vi for Linux, please.

5. The DEVICE=GRUB.EXE line can be used together with other DEVICE commands
such as DEVICE=HIMEM.SYS and DEVICE=EMM386.EXE. The GRUB.EXE line should
occur before the EMM386.EXE line in order to avoid the rejection by EMM386.
Update: Since 0.4.2, GRUB.EXE works well even after EMM386.EXE is loaded.

6. In any case mentioned above, you can return back to DOS by quit command.

7. Memory usage about command-line menu: The 4KB command-line menu starts at
physical address 0x0800 and ends at 0x17FF.

******************************************************************************
***          New Syntax for the DEFAULT/SAVEDEFAULT Commands               ***
******************************************************************************

In addition to the original usage of "default NUM" and "default saved", now
there is a new usage of "default FILE", like this:

		default (hd0,0)/default

Note that FILE must have a valid DEFAULT file format. A sample DEFAULT file
is included in the release. You may copy it to wherever you like, but you
should avoid modifying its content manually. The DEFAULT file may be used
in this way:

(1) First, you should copy a default file with valid format to somewhere in
your operating system.

(2) Secondly, you should use the "default FILE" command of GRUB to announce
the use of FILE as our new default file for being written by "savedefault".

(3) Then, you may use "savedefault" command to save the desired entry number
into this new default file.

(4) OK, at next boot, you may read the saved entry number by using the same
"default FILE" command as mentioned in above (2).

And the SAVEDEFAULT command now accept an options `--wait=T', like this:

		savedefault --wait=5

If `--wait=T' is specified and T is non-zero, savedefault will prompt
the user with a message just before it writes to disk. The write operation
will be cancelled in T seconds if the `Y' key was not pressed.

Here is a sample menu.lst file:

#--------------------begin menu.lst---------------------------------------
color black/cyan yellow/cyan
timeout 30
default /default

title find and load NTLDR of Windows NT/2K/XP
find --set-root /ntldr
chainloader /ntldr
savedefault --wait=2

title find and load CMLDR, the Recovery Console of Windows NT/2K/XP
fallback 2
find --set-root /cmldr
chainloader /cmldr
#####################################################################
# write string "cmdcons" to memory 0000:7C03 in 2 steps:
#####################################################################
# step 1. Write 4 chars "cmdc" at 0000:7C03
write 0x7C03 0x63646D63
# step 2. Write 3 chars "ons" and an ending null at 0000:7C07
write 0x7C07 0x00736E6F
savedefault --wait=2

title find and load IO.SYS of Windows 9x/Me
find --set-root /io.sys
chainloader /io.sys
savedefault --wait=2

title floppy (fd0)
chainloader (fd0)+1
rootnoverify (fd0)
savedefault --wait=2

title find and boot Linux with menu.lst already installed
find --set-root /sbin/init
savedefault --wait=2
configfile /boot/grub/menu.lst

title find and boot Mandriva with menu.lst already installed
find --set-root /etc/mandriva-release
savedefault --wait=2
configfile /boot/grub/menu.lst

title back to dos
savedefault --wait=2
quit

title commandline
savedefault --wait=2
commandline

title reboot
savedefault --wait=2
reboot

title halt
savedefault --wait=2
halt
#--------------------end menu.lst---------------------------------------

Note 1:	The file DEFAULT must exist and have a proper format as stated above.
	Or else, the default/savedefault commands won't function well.

Note 2:	The file DEFAULT which is in the same dir as a certain MENU.LST file
	is called associated with the MENU.LST file.

Note 3:	The associated DEFAULT file will take effect automatically if there
	are no `default' commands present.

Note 4:	Just before a menu file gains control(e.g., it is the associated
	MENU.LST of a GRLDR file, or it was specified via
	`grub.exe --config-file=(DEVICE)/PATH/YOUR_MENU_FILE', or it was
	specified by the `configfile' command of grub), its associated
	DEFAULT file will be used if present, until an explicit `default'
	command is encountered.

******************************************************************************
***                   The New `cdrom' Command Syntax                       ***
******************************************************************************

1. Initialize the ATAPI CDROM devices:

	grub> cdrom --init

   This will display the number of atapi cdroms found: atapi_dev_count

2. Stop the ATAPI CDROM devices:

	grub> cdrom --stop

   This will set atapi_dev_count to 0.

3. Add IO ports for searching the atapi cdrom devices. For example:

	grub> cdrom --add-io-ports=0x03F601F0

After running `cdrom --init' and `map --hook', the cdroms can be accessed
through devices (cd0), (cd1), ...

Note 1: If the system does not fully support the ATAPI CD-ROM specifications,
	you will encounter failure when trying to access the (cdX) devices.

Note 2: After doing a `cdrom --stop', you should do a `map --unhook'. Of
	course you may `map --hook' again if there are mapped drives.

Note 3: After adding IO ports, you should do a `map --unhook' followed by a
	`cdrom --init' and then followed by a `map --hook'.

	By default, these ports are used for searching cdroms(so they needn't
	be added):

		0x03F601F0, 0x03760170, 0x02F600F0,
		0x03860180, 0x6F006B00, 0x77007300.

Note 4: The BIOS might have offered a cdrom interface. It would be (cd). After
	`cdrom --init' and `map --hook', we might have our (cd0), (cd1), ...
	available. It is likely that one of them could access the same media
	as the BIOS-offered (cd).

Note 5: You may access the (cd) and (cdX)'es in the blocklist way. Example:

		cat --hex (cd0)16+2

	The cdrom sectors are big sectors with a size of 2048 bytes.

Note 6:	The iso9660 filesystem driver has Rock-Ridge extension support, but
	has no Joliet extension support. So you may encounter failure when
	you attempt to read files on a Joliet CD.

Note 7: The (cd) or (cdX)'es can be booted now. Examples:

		chainloader (cd)
		boot

		chainloader (cd0)
		boot

		chainloader (cd1)
		boot

	You should already have access to the CD sectors before you can
	chainload it.

******************************************************************************
***                   About the New `setvbe' Command                       ***
******************************************************************************

Gerardo Richarte contributed the `setvbe' code and the following comment:

	New command is `setvbe', and can be used to change the video mode
	before executing the kernel.

	For example, you can do

		setvbe 1024x768x32

	this will scan the list of available modes and set it, and
	automatically append a `video=' option to each subsequent kernel
	command-line. The appended `video=' option is like this:

		video=1024x768x32@0xf0000000,4096

	where 0xf0000000 is the video framebuffer address as reported by vbe,
	and 4096 is the size of a scanline in bytes (also as reported by vbe).

	This is really useful if you want to give some graphics support to your
	OS, but you don't want to implement any video functionality other than
	writing a pixel to video memory.


******************************************************************************
***                  A bug was found in the CDROM driver                   ***
******************************************************************************

It seems the cdrom must be connected as the master device of an IDE controller.

If cdrom is slave, the driver will fail to read the cdrom sectors. Hope someone

could fix this problem.


******************************************************************************
***                        BIOS and the (cd) drive                         ***
******************************************************************************

When BIOS boots a no-emulation-mode bootable CD-ROM, it allocates a BIOS drive
number to the CD. If the boot image of the CD-ROM is grldr or stage2_eltorito,
then GRUB can access the CD-ROM media through the drive number allocated by
BIOS. The device name of the CD-ROM is (cd).

BIOS can allocate a BIOS drive number to a no-emulation-mode CDROM even when
the CDROM is not bootable. QEMU has done so. At boot time, GRUB4DOS will
search drives 0x80-0xFF for a possible no-emulation-mode CDROM drive allocated
by BIOS. So if BIOS offered a CDROM interface of int13 EBIOS functions 41h-4Eh,
then the (cd) device will be automatically available in GRUB4DOS.


******************************************************************************
***              The way of disk emulation changed greatly                 ***
******************************************************************************

The way of disk emulation has changed greatly since 0.4.2 final. Please don't
mix newer versions with older versions when disk emulation features are used.

The newer versions won't automatically unhook emulations established in a
previous grub4dos environment. The GRUB.EXE of an older version will
automatically dismiss emulations established earlier, before transferring
control to the main grub program(i.e., pre_stage2).


******************************************************************************
***            FreeDOS EMM386 v2.26 (2006-08-27) VCPI problem              ***
******************************************************************************

The VCPI function "AX=DE0Ch - Switch From Protected Mode to V86 Mode" of
FreeDOS EMM386 v2.26 was not implemented properly(it always hangs). As an
alternative, you can use Microsoft's EMM386 instead.

Even while emm386 is running, grub.exe can be started. But if you try to quit
to DOS from grub4dos by using the `quit' command, the VCPI function DE0C will
be called. If EMM386 is of Microsoft, everything goes ok. If EMM386 is of
FreeDOS, the machine will hang.


******************************************************************************
***                 New options for map were added                         ***
******************************************************************************

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
< 0xA0.If the RAM DRIVE is a cdrom image, you should set 0xA0<= 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.


******************************************************************************
***                   About the new map option --in-situ                   ***
******************************************************************************

--in-situ is used with hard drive images or hardrive partitions. With an
in-situ map, we can typically use a logical partition as a primary partition.

In-situ map is a whole drive map. It only virtualize the partition table and
the number of hidden sectors in the BPB of the DOS Boot Record.

While disk emulation may encounter various problems with win9x, the in-situ map
works fine with win9x.

Note that --in-situ will not change the real partition table.

Example:

	map --in-situ (hd0,4)+1 (hd0)


******************************************************************************
***                      The PARTNEW Command Syntax                        ***
******************************************************************************

Besides the mappings in the above section, you may instead choose to create a
new primary partition with the PARTNEW command. PARTNEW can generate a primary
partition entry (in the partition table) for a logical partition.

For example,

	partnew (hd0,3) 0x07 (hd0,4)+1

where the file (hd0,4)+1 stands for the whole partition (hd0,4). This command
will create a new primary partition (hd0,3) whose type is 0x07 and whose
contents/data is the same as that of the logical partition (hd0,4).

Just like a whole logical partition, a contiguous partition image file can
also be used with PARTNEW:

	partnew (hd0,3) 0x00 (hd0,0)/my_partition.img

The type 0x00 indicates a type-auto-detection of the image MY_PARTITION.IMG.
The above command will create a new primary partition (hd0,3) with a proper
type and with contents/data being exactly that of the contiguous file
(hd0,0)/my_partition.img.

PARTNEW will automatically correct the "hidden sectors" in the BPB and the
modification will be permanent. And PARTNEW modifies the partition table
permanently.

In addition to creating new partition entries, PARTNEW can also be used to
delete(erase, or wipe) a primary partition entry. For example,

	partnew (hd0,3) 0 0 0

which will empty the last entry in the partition table in MBR. Generally,
you should use the form of "partnew PARTITION 0 0 0" to erase the entry.
Note that only the entry would be erased, and the data stored in the partition
will not be touched.

******************************************************************************
***              Newly implemented operators `&&' and `||'                 ***
******************************************************************************

This implementation is very simple. It does not handle operator nesting.

Usage of `&&':

	command1 && command2

Description:

	If command1 returns true, then command2 will be executed.

Usage of `||':

	command1 || command2

Description:

	If command1 returns false, then command2 will be executed.

Examples:

	is64bit && default 0
	is64bit || default 1

2010-11-04
	Add new operators "|", ">" , ">>"
Usage:
	command1 | command2

	command > file
	or
	command >> file

Node: The file must already exist, GRUB4DOS can not create file or change the file size.
Examples:
	cat /test.txt > /abcd.txt


******************************************************************************
***          Three new commands is64bit, errnum and errorcheck             ***
******************************************************************************

is64bit and errnum retrieve the value of is64bit and errnum respectively.

errorcheck controls whether or not the error will be handled. By default,
errorcheck is on, and menu script execution will stop on error. If errorcheck
is off, the script will continue to execute upto a boot command. A boot command
will turn the errorcheck on.


******************************************************************************
***              Use numeric keys to select a menu entry                   ***
******************************************************************************

If, for example, you intend to goto entry #25, you may press 2 followed by 5.


******************************************************************************
***           Use the INSERT key to debug step by step at startup          ***
******************************************************************************

Some buggy machines could fail to enter grub4dos environment. They might hang
or reboot unexpectedly. Press INSERT as quickly as possible on startup, and
you can get a chance to single-step the boot process and see how far it can
go, and then report bugs.


******************************************************************************
***             The debug command syntax has been changed                  ***
******************************************************************************

The DEBUG command now can be used to control the verbosity of command output:

		debug [ on | off | normal | status | INTEGER ]

0 or off for silent
1 or normal for normal
2 to 0x7FFFFFFF or on for verbose


******************************************************************************
***                     GRUB4DOS and Windows Vista                         ***
******************************************************************************

First, use the following command to create a boot entry:

	bcdedit /create /d "GRUB for DOS" /application bootsector

The result will look like this:

The entry {05d33150-3fde-11dc-a457-00021cf82fb0} was successfully created.

The long string {05d33150-3fde-11dc-a457-00021cf82fb0} is the id for this
entry.

Then, use the following commands to set boot parameters:

	bcdedit /set {id} device boot
	bcdedit /set {id} path \grldr.mbr
	bcdedit /displayorder {id} /addlast

Please replace {id} with the actual id returned from the previous command.

Finally, copy GRLDR.MBR to C:\ or wherever your boot drive is, and copy GRLDR
and menu.lst to the root directory of any FAT16/FAT32/EXT2/NTFS partition.

Note: A boot partition should be the active primary partition with BOOTMGR
      inside. The `device boot' indicates grldr.mbr should be in the boot
      partition.

Lianjiang has written down a script to automate the tasks:

	@echo off
	rem by lianjiang
	cls
	echo.
	echo   Please run as administrator
	echo.
	pause
	set gname=GRUB for DOS
	set vid=
	set timeout=5
	bcdedit >bcdtemp.txt
	type bcdtemp.txt | find "\grldr.mbr" >nul && echo. && echo  BCD entry existing, no need to install. && pause && goto exit
	bcdedit  /export "Bcd_Backup" >nul
	bcdedit  /create /d "%gname%" /application bootsector >vid.ini
	for,/f,"tokens=2 delims={",%%i,In (vid.ini) Do (
                  set vida=%%i
	)
	for,/f,"tokens=1 delims=}",%%i,In ("%vida%") Do (
                  set vid={%%i}
	)
	echo %vid%>vid.ini
	bcdedit  /set %vid% device boot >nul
	bcdedit  /set %vid% path \grldr.mbr >nul
	bcdedit  /displayorder %vid% /addlast >nul
	bcdedit  /timeout  %timeout% >nul
	if exist grldr.mbr copy grldr.mbr %systemdrive%\ /y && goto exit
	echo.
	echo   Please copy grldr.mbr to %systemdrive%\
	echo.
	pause
	:exit
	del bcdtemp.txt >nul
-------------------------------------------------------------------
Update: Fujianabc pointed out that

	bcdedit  /set %vid% device boot >nul

should be changed to

	bcdedit  /set %vid% device partition=%SystemDrive% >nul
-------------------------------------------------------------------

You still need to copy grldr yourself.

Notice: It's possible to modify the BCD entry from a different OS, you just
need to specify the location of BCD:

	bcdedit /store D:\boot\BCD ...

Notice: These commands need elevated privileges, they should be used inside
cmd.exe which is started with "Run as administrator".

Notice: People has reported that some version of Vista doesn't support
creating file in C:\ with no extension, even with administrator privileges.
This means grldr can't be placed in C:\. You can solve this by either copy
grldr to another partition, or rename grldr to something like grub.bin. Please
see the following section on how to do this.


******************************************************************************
***                          PXE device                                    ***
******************************************************************************

If PXE service is found at startup, GRUB4DOS will create a virtual device
(pd), through which files from the tftp server can be accessed. You can setup
a diskless boot environment using the following steps:

Client side

You need to boot from PXE ROM.

Server side

You need to configure a dhcp server and a tftp server. In the dhcp server, use
grldr as boot file.

You may also want to load a different menu.lst for different client. GRUB4DOS
will scan the following location for configuration file:

	[/mybootdir]/menu.lst
	[/mybootdir]/menu.lst/01-88-99-AA-BB-CC-DD
	[/mybootdir]/menu.lst/C000025B
	[/mybootdir]/menu.lst/C000025
	[/mybootdir]/menu.lst/C00002
	[/mybootdir]/menu.lst/C0000
	[/mybootdir]/menu.lst/C000
	[/mybootdir]/menu.lst/C00
	[/mybootdir]/menu.lst/C0
	[/mybootdir]/menu.lst/C
	[/mybootdir]/menu.lst/default

Here, we assume the network card mac for the client machine is
88:99:AA:BB:CC:DD, and the ip address is 192.0.2.91 (C000025B). /mybootdir is
the directory of the boot file, for example, if boot file is /tftp/grldr, then
mybootdir=tftp.

If none of the above files is present, grldr will use its embeded menu.lst.

This is a menu.lst to illustrate how to use files from the tftp server.

	title Create ramdisk using map
	map --mem (pd)/floppy.img (fd0)
	map --hook
	rootnoverify (fd0)
	chainloader (fd0)+1

	title Create ramdisk using memdisk
	kernel (pd)/memdisk
	initrd (pd)/floppy.img

You can see that the menu.lst is very similar to normal disk boot, you just
need to replace device like (hd0,0) with (pd).

There are some differences between disk device and pxe device:

1. You can't list files in the pxe device.

2. The blocklist command will not work with a file in the pxe device.

3. You must use --mem option if you want to map a file in the pxe device.

When you use chainloader to load file from the pxe device, there is a option
you can use:

	chainloader --raw (pd)/BOOT_FILE

Option --raw works just like --force, but it load file in one go. This can
improve performance in some situation.

You can use the pxe command to control the pxe device.

1. pxe

	If used without any parameter, pxe command will display current
	settings.

2. pxe blksize N

	Set the packet size for tftp transmission. Minimum value is 512,
	maximum value is 1432. This parameter is used primarily for very old
	tftp server where packet larger than 512 byte is not supported.

3. pxe basedir /dir

	Set the base directory for files in the tftp server. If

		pxe basedir /tftp

	then all files in the pxe device is related to directory /tftp, for
	example, (pd)/aa.img correspond to /tftp/aa.img in the server.

	The default value of base directory is the directory of the boot file,
	for example, if boot file is /tftp/grldr, then default base directory
	is /tftp.

4. pxe keep

	Keep the PXE stack. The default behaviour of GRUB4DOS is to unload
	the PXE stack just before it exits.

5. pxe unload

	Unload the PXE stack immediately.



******************************************************************************
***                  New Feature of Relative Path Support                  ***
******************************************************************************

Use the `root' or `rootnoverify' command to specify the `working directory'.

For example:

		root  (hd0,0)/boot/grub

This specifies that the working dir is (hd0,0)/boot/grub. So all subsequent
filenames of the form "/..." will actually refer to (hd0,0)/boot/grub/...

That is to say:

		cat  /menu.lst

will be equivalent to

		cat  (hd0,0)/boot/grub/menu.lst



******************************************************************************
***                 Notation For The Current Root Device                   ***
******************************************************************************


The notation `()' can be used to access the current root device. You may use
`find --set-root ...' to set the current root device, but the find command
does not set the `working dir' of the root device. In this case you should
use `()' to set the working dir after the find command:

		root  ()/boot/grub

Update 2008-05-01:

	FIND can also set the `working directory' now. For example:

		find  --set-root=/tmp  /boot/grub/menu.lst

	It is equivalent to this pair of commands:

		find  --set-root  /boot/grub/menu.lst
		root  ()/tmp


******************************************************************************
***                   The new map option --a20-keep-on                     ***
******************************************************************************


Along with 0.4.3 final, map has a new option --a20-keep-on which is related to
A20 control after a memdrive sector access. Usage:

	map --a20-keep-on=0

It should be used before the "map --hook" command.

By default, A20 will be always on after an RAM INT13 sector access. If
"map --a20-keep-on=0" is used, the A20 status after the INT13 call will be the
same as that before the INT13 call.


******************************************************************************
***                  The CDROM emulation (virtualization)                  ***
******************************************************************************

The CDROM emulation is sometimes called ISO emulation. Here is an example:

	map  (hd0,0)/myiso.iso  (hd32)
	map  --hook
	chainloader  (hd32)
	boot

if myiso.iso is not contiguous and you have enough memory, add a --mem option:

	map  --mem  (hd0,0)/myiso.iso  (hd32)
	map  --hook
	chainloader  (hd32)
	boot

Note: (hd32) is a grub drive number equivalent to (0xA0). If a virtual drive is
specified with a drive number greater than or equal to 0xA0, then it will be
treated as a cdrom (i.e., with 2048-byte big sectors).

Like normal disk emulations, the CDROM emulation also (mainly) works with
real-mode OSes. After a protected-mode OS kernel (such as
WinNT/2K/XP/VISTA/LINUX) gains control, the OS would have no ability to access
the virtual CDROM through BIOS int13.

DOS/Win9x users may google for ELTORITO.SYS and use it in CONFIG.SYS as a
device driver for the virtual cdrom.

Example usage of eltorito.sys in CONFIG.SYS:

	device=eltorito.sys /D:oemcd001

Corresponding MSCDEX command which can be placed in AUTOEXEC.BAT:

	MSCDEX /D:oemcd001 /L:D


Due to some bugs found in eltorito.sys, the driver could fail to load. If you
encounter such problems, then you may replace (hd32) with (0xFF) for the
virtual cdrom drive number and try again.


******************************************************************************
***                  The New Command CHECKRANGE                            ***
******************************************************************************

Checkrange checks whether or not the return value of a command is in the
specified range or ranges.

Usage:		checkrange  RANGE  COMMAND

Here are some examples for RANGE:

	3 is a range containing only the number 3
	3:3 is equivalent to 3
	3:8 is a range containing the numbers 3, 4, 5, 6, 7, 8
	3,4,5,6,7,8 is equivalent to 3:8
	3:5,6:8 is also equivalent to 3:8
	3,4:7,8 is also equivalent to 3:8

Note: You should not insert spaces into a range.

Here is an example showing where the checkrange can be used:

	checkrange 0x05,0x0F,0x85 parttype (hd0,1) || hide (hd0,1)

which means: if (hd0,1) is not an extended partition, then hide it.


******************************************************************************
***                       The New Command TPM                              ***
******************************************************************************

The "tpm --init" uses 512-byte data at 0000:7C00 as buffer to initialise TPM.

Before you boot VISTA's BOOTMGR, you might have to use the "tpm --init"
command on some machines. Normally you want to issue the "tpm --init" command
after a CHAINLOADER command.


******************************************************************************
***               Delimitors or comments between titles                    ***
******************************************************************************

It is possible to use titles as delimitors or comments. A title(or menu item)
is called unbootable if all of its menu commands are not boot-sensitive.

The following commands are boot-sensitive(and others are not boot-sensitive):

	boot
	bootp
	chainloader
	configfile
	embed
	commandline
	halt
	install
	kernel
	pxe
	quit
	reboot
	setup

An unbootable title will be skipped when the user presses the Up Arrow or Down
Arrow keys. Even the unbootable menu item can get accessed(and executed) by
using the Left Arrow and/or Right Arrow keys. Examples:

	title This is an UNBOOTABLE entry(so this line is also a comment)
		pause --wait=0 This title is a comment. Nothing to do.
		pause --wait=0 You can use non-boot-sensitive commands here
		pause --wait=0 of any kind and as many as you would like.
		help
		help root
		help chainloader
		help parttype
		clear
	title ------------------------------------------------------------
		pause --wait=0 This title is a delimitor. Nothing to do.
		pause --wait=0 You can use non-boot-sensitive commands here
		pause --wait=0 of any kind and as many as you would like.
		clear
		help
		help boot
	title ============================================================
		pause --wait=0 This title is a delimitor. Nothing to do.
		pause --wait=0 You can use non-boot-sensitive commands here
		pause --wait=0 of any kind and as many as you would like.
		help
		clear
		help pause
	title ************************************************************
		pause --wait=0 This title is a delimitor. Nothing to do.
		pause --wait=0 You can use non-boot-sensitive commands here
		pause --wait=0 of any kind and as many as you would like.
		help kernel
		help
		clear

Note: An unbootable menu item must contain at least one command. If there
are no commands for a title, the title will be simply discarded and disappear.


******************************************************************************
***                           Bifurcate drives                             ***
******************************************************************************

Some machines apply different actions to a drive between CHS and LBA mode.
When you read sectors using standard BIOS call int13/AH=02h, you might find
out the drive is a floppy. But when you read sectors using extended BIOS
call(EBIOS) int13/AH=42h, you could know the drive is a cdrom. Such a drive
is called bifurcate.

A bifurcate drive can have two drive numbers: one is the normal BIOS drive
number between 00 and FF in hexa, and this drive uses only CHS mode disk
access(standard BIOS int13/AH=02h); the other is the normal BIOS drive number
(Bitwise) OR'ed by 0x100(i.e., 256 in decimal), and this drive uses only
LBA mode disk access(EBIOS int13/AH=42h). For example, if the drive 0x00
(i.e., the first floppy) is bifurcate, then the drive (0x00) uses CHS mode
to access its sectors, and the drive (0x100) uses LBA (meaning EBIOS) mode
to access its sectors.

The geometry command can report the disk access mode for bifurcate drives as
BIF instead of the conventional CHS or LBA.

Known bifurcate drives. Virtual PC and some real machines are found to create
a bifurcate floppy drive when they boot from a floppy-emulation mode bootable
cdrom. The "geometry (fd0)" will show

	drive 0x00(BIF): C/H/S=...Sector Count/Size=.../512

and "geometry (0x100)" will show

	drive 0x100(BIF): C/H/S=...Sector Count/Size=.../2048

Actually (0x100) can access the whole cdrom, you may "ls (0x100)/" and find
your files on the cdrom(not the files inside the booted floppy image). Of
course "ls (fd0)/" will list the files inside the booted floppy image.

Note that only some (real or virtual) machines have this action, others
will not produce bifurcate drives.


******************************************************************************
***                       GRLDR as PXE boot file                           ***
******************************************************************************

GRLDR can be used as the PXE boot file on a remote/network server. The (pd)
device is used to access files on the server. When GRLDR is booted through
network, it will use its preset menu as the config file. However, you may use
a "pxe detect" command, which acts this way:

    * First, it will search for the config file "menu.lst" in the same dir as
      grldr.

    * Second, it will search for the config file using the hardware type (using
      its ARP type code) and address, all in hexadecimal with dash separators;
      for example, for an Ethernet (ARP type 1) with address 88:99:AA:BB:CC:DD
      it would search for the filename 01-88-99-AA-BB-CC-DD. 

    * Next, it will search for the config file using its own IP address in
      upper case hexadecimal, e.g. 192.0.2.91 -> C000025B. If that file is not
      found, it will remove one hex digit and try again. At last, it will try
      looking for a file named default (in lower case). As an example, if the
      boot file name is /mybootdir/grldr, the Ethernet MAC address is
      88:99:AA:BB:CC:DD and the IP address 192.0.2.91, it will try following
      files (in that order): 

       /mybootdir/menu.lst
       /mybootdir/menu/01-88-99-AA-BB-CC-DD
       /mybootdir/menu/C000025B
       /mybootdir/menu/C000025
       /mybootdir/menu/C00002
       /mybootdir/menu/C0000
       /mybootdir/menu/C000
       /mybootdir/menu/C00
       /mybootdir/menu/C0
       /mybootdir/menu/C
       /mybootdir/menu/default

You cannot directly map an image file on (pd). You must map it in memory using
the --mem option. For example,

	map --mem (pd)/images/floppy.img (fd0)
	map --hook
	chainloader (fd0)+1
	rootnoverify (fd0)
	boot

One more example,

	map --mem (pd)/images/cdimage.iso (0xff)
	map --hook
	chainloader (0xff)
	boot


******************************************************************************
***                           Conditional find                             ***
******************************************************************************

The new find syntax allows to find a device conditionally.

	find [OPTIONS] [FILENAME] [CONDITION]

CONDITION is a normal grub command which returns TRUE or FALSE.

OPTIONS:
	--set-root		set the current root device.
	--set-root=DIR		set current root device and working directory to DIR.
			please also see "Notation For The Current Root Device".
	--ignore-cd		skip search on (cd).
	--ignore-floppies	bypass all floppies.
	--devices=DEVLIST	specify the search devices and order.
		  DEVLIST	u->(ud)
				n->(nd)
				p->(pd)
				h->(hdx)
				c->(cd)
				f->(fdx)
				default: upnhcf

	Example 1:

		find

	This will list all partitions, all floppies and the (cd).

	Example 2:

		find +1

	This will list all devices with a known filesystem.

	Example 3:

		find checkrange 0xAF parttype

	This will list all partitions with ID=0xAF.

	Example 4:

		find /ntldr checkrange 0x07 parttype

	This will list all partitions with ID=0x07 and existing /ntldr.

	Example 5:
		find --set-root /ntldr
	This will set the first device it finds to current root device.

	Example 6:
		find --set-root --devices=h /bootmgr
	Same of Example 5.but search on hard disk only.

	Example 7:
		find --set-root --devices=h makeactive --status
	This will set current root device to first active partition.

******************************************************************************
***                    Use 'pxe detect' in preset-menu                     ***
******************************************************************************

Now the "pxe" command has a new subcommand "detect":

		pxe detect [BLOCK_SIZE] [MENU_FILE]

BLOCK_SIZE specifies the block size for PXE. If it is not specified or it is
0, then grub4dos will go through a probing process and get a proper value
for data transfer.

MENU_FILE specifies the config file on the PXE server. If omitted, a standard
config file in the menu.lst sub-dir will gain control. For a description on
the config files in the menu.lst sub-dir, please refer to the section
"GRLDR as PXE boot file" above.
If MENU_FILE starts in a "/", then the MENU_FILE on the PXE server will gain
control, else(if MENU_FILE does not start in a "/") no menu will be executed.

Normally you want to use a "pxe blksize ..." or a "pxe detect ..." command
before you access the (pd) device, since the default blocksize of 512 might
not work on your system.


******************************************************************************
***                    Use 'configfile' in preset-menu                     ***
******************************************************************************

Now the preset menu holds the highest priority. It will gain control prior to
the menu.lst on the boot device. If a 'configfile' command(without specifying
any file as the parameter) occurs in the menu init command group of the preset
menu, then control will go to the menu.lst on the boot device.

Note: You should better not use "configfile ANOTHER_MENU" frequently in your
menu.lst file, because it could create infinite loop and thus hang your
computer.


******************************************************************************
***                    New command 'dd' to copy files                      ***
******************************************************************************

Usage:

dd if=IF of=OF [bs=BS] [count=C] [skip=IN] [seek=OUT] [buf=ADDR] [buflen=SIZE]

Copy file IF to OF. BS is blocksize in bytes, default to 512. C is blocks to
copy, default is total blocks in IF. IN specifies number of blocks to skip
when read, default is 0. OUT specifies number of blocks to skip when write,
default is 0. Skipped blocks are not touched. Both IF and OF must exist.

Both IF and OF must have a leading device name, i.e.,  of the form `(...)'.
You may use `()' for the current root device.

dd can neither enlarge nor reduce the size of OF, the leftover tail of IF
will be discarded. OF cannot be a gzipped file. If IF is a gzipped file,
it will be decompressed automatically when copying.

dd is dangerous, use at your own risk. To be on the safe side, you should
only use dd to write a file in memory.

In some cases when writing a file in a NTFS volume, dd might fail.

If you attempt to write a device or a block file that is not in memory by
starting dd in a menu, you will safely be refused :-) (Update: no restrictions
now)

Update: New options are implemented for user defined buffer. By default,
the buffer is at address 0x50000, and length is 0x10000(=64KB). You cannot
specify ADDR to be lower than 0x100000(=1MB). Besides, you must specify SIZE
larger than 0x10000(=64KB). Normally you want ADDR >= 0x1000000(=16MB), and
SIZE also >= 16MB. A large SIZE could speed up the progression of dd.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!!
!!!!    Caution! Both IF and OF can be a device name which stands for     !!!!
!!!!    all the sectors on the device. Take utmost care!                  !!!!
!!!!______________________________________________________________________!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


******************************************************************************
***              New command 'uuid' to identify partitions                 ***
******************************************************************************

Usage:

	uuid [DEVICE] [UUID]

If DEVICE is not specified, search for filesystem with UUID in all partitions
and set the partition containing the filesystem as new root (if UUID is
specified), or just list uuid's of all filesystems on all devices (if UUID is
not specified). If DEVICE is specified, return true or false according to
whether or not the DEVICE matches the specified UUID (if UUID is specified),
or just list the uuid of DEVICE (if UUID is not specified).

Example 1:

	find --set-root uuid () 7f95820f-5e33-4e6c-8f50-0760bf06d79c

which will find a partition with uuid=7f95820f-5e33-4e6c-8f50-0760bf06d79c
and set the partition as root if found.

Example 2:

	uuid ()

which will print the uuid of the current root device.


******************************************************************************
***                     gfxmenu support in grub4dos                        ***
******************************************************************************

Gfxmenu support has been added to grub4dos. To use it, you must first find the
message file you need, then load it in menu.lst with command like this:

	gfxmenu /message

This should be a gloabl command, that is, not inside any menu item. Also, it
can only be used in configure file, running it in console mode does not work.

gfxmenu does not work in conjunction with the password feature.

There are two major format of message file. Old format is created with gfxboot
3.2.* or older (size of message file is normally about 150K), while new format
is created with gfxboot 3.3.* and later (size of message file is normally above
300K). Both format are supported in grub4dos.


******************************************************************************
***           Use 'write' to write a string into a device or file          ***
******************************************************************************

Usage:

	write [--offset=SKIP] ADDR_OR_FILE INTEGER_OR_STRING

SKIP is an integer and defaults to 0.

If ADDR_OR_FILE is an integer, then it is treated as a memory address, and
INTEGER_OR_STRING must be an integer value. The integer INTEGER_OR_STRING
will be written to address (ADDR_OR_FILE + SKIP).

If ADDR_OR_FILE is a device or a file, then INTEGER_OR_STRING is treated as
a string which will be written to ADDR_OR_FILE at offset SKIP (in bytes).

The string is quoted with nothing, that is, neither with the single quote
char(') nor with the double quote char(").

Space char must be quoted with back slash(\). (Update: need not now)

Single quote char(') and double quote char(") are not interpreted specially
and can be used directly in the string.

Some C-style quote sequences are interpreted as follows:

	\NNN	character with octal value NNN (1 to 3 digits)

	\\	backslash

	\a	alert (BEL)

	\b	backspace

	\f	form feed

	\n	new line

	\r	carriage return

	\t	horizontal tab

	\v	vertical tab

	\xHH	byte with hexadecimal value HH (1 to 2 digits)

Just like dd, the write can neither enlarge nor reduce the size of the
destination file, the leftover tail of the string will be discarded.
The destination file cannot be a gzipped file.

Again like dd, the write command is also dangerous, use at your own risk.
And to be on the safe side, you should only write to memory files.

In some cases when writing a file in a NTFS volume, the write might fail.

If you attempt to write a device or a block file that is not in memory by
using write in a menu, you will safely be refused :-) (Update: no restrictions
now)


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!!
!!!!    Caution! The file to write can be a device name which stands      !!!!
!!!!    for all the sectors on the device. Take utmost care!              !!!!
!!!!______________________________________________________________________!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


******************************************************************************
***                 Item-by-item help text for menu entries                ***
******************************************************************************


The help message at the bottom of the screen will vary as you choose the menu.

You may append your help text to the title line. The help text must begin
with "\n", for example:

	title This is the title\nThis is the help text.\nAnd this is the 2nd line of the help text.

Some C-style quote sequences are interpreted as stated in the section above.


******************************************************************************
***        initrd can load multiple cpio files for Linux 2.6 kernels       ***
******************************************************************************

Usage:

	initrd FILE [FILE ...]

Note 1: You should not load more than one oldstyle disk images in this way,
because this is not supported by Linux kernel.

Note 2: The FILEs should be specified in the same order as with syslinux.

******************************************************************************
***            access some internel variables at a fixed location          ***
******************************************************************************

Address		Length		Description
=========	========	==============================================
0000:8208	4 (DWORD)	install_partition (the boot partition)
0000:8280	4 (DWORD)	boot_drive (the boot drive)
0000:8284	4 (DWORD)	pxe_yip (your ip)
0000:8288	4 (DWORD)	pxe_sip (server ip)
0000:828C	4 (DWORD)	pxe_gip (gateway ip)
0000:8290	8 (QWORD)	filesize (file size by last "cat --length=0")
0000:8298	4 (DWORD)	saved_mem_upper (extended memory size in KB)
0000:829C	4 (DWORD)	saved_partition (current root partition)
0000:82A0	4 (DWORD)	saved_drive (current root drive)
0000:82A4	4 (DWORD)	no_decompression (no auto gunzip)
0000:82A8	8 (QWORD)	part_start (start sector of last partition)
0000:82B0	8 (QWORD)	part_length (total sectors of last partition)

Note 1: Filesize can be initialised/modified by using "cat --length=0 FILE".
Note 2: You should not write these variables by hand(should read only).
Note 3: You may use 1K at 6000:0000 for your own varibles(See note 4).
Note 4: The read command now returns the integer value at the given address.
Note 5: Grub4dos does not have the variable expansion feature. You can only
	use integer variables. You need not declare them, but use the memory
	address directly. Usually you want to use variables as a logical
	value or in a command for conditional test, e.g., of this form:
		 "checkrange RANGE read ADDR"
Note 6: no_decompression, saved_drive and saved_partition are writable.


******************************************************************************
***            possibility to run another menu.lst after gfxmenu           ***
******************************************************************************

Notice the use of CONFIGFILE after GFXMENU in the following example:

	# The menu.lst file for gfxmenu
	default=0
	timeout=5
	gfxmenu /message
	configfile /another.lst
	title 0..........
	................
	title 1..........
	................
	title 2..........
	................
	# End of menu.lst

	# Begin another.lst
	default=0
	timeout=5
	title 0..........
	................
	title 1..........
	................
	title 2..........
	................
	# End of another.lst

This will try gfxmenu command first. On exit(or on failure) control will go
to another.lst file.


******************************************************************************
***                   a range of drives can be unmapped                    ***
******************************************************************************

Usage:

	map --unmap=RANGE

RANGE is a range of BIOS drive numbers to be unmapped. BIOS drive number 0
is for the first floppy, 1 is for the second floppy; 0x80 is for the first
hard drive, 0x81 is for the second hard drive, etc; virtual cdrom (hd32)
corresponds to BIOS drive number 0xA0, (hd33) corresponds to 0xA1, etc.

For description on RANGE, please refer to section `The New Command CHECKRANGE'
above.

Example 1:

	map --unmap=0,0x80,0xff

This will unmap virtual floppy (fd0), virtual hard drive (hd0) and virtual
cdrom (0xff).

Example 2:

	map --unmap=0:0xff

This will unmap all virtual floppies, all virtual hard drives and all virtual
cdroms.

Note 1: Normally a `map' command will add an item in the drive map table for
	a virtual drive. But `--unmap' means items in the drive map table
	(for the specified virtual drives) will be deleted.
Note 2:	The --unhook option only breaks the INT13 hook(to the inerrupt
	vector table). It will not affect the drive map table. And later on
	execution of a `boot' command, the INT13 disk emulation routine will
	automatically get hooked(to the interrupt vector table) when needed
	(e.g., the drive map table is non-empty) even if it has been unhooked.
Note 3: Usually you want to do a `map --rehook' after you have changed the
	drive map table.


******************************************************************************
***                         geometry tune and sync                         ***
******************************************************************************

When a USB storage device is connected to a (or another) machine, the geometry
in the partition table or in the BPB of the volume could be invalid, and the
machine could hang at boot time. So you need to find out the correct geometry
for the drive (use `geometry --tune'), and then update the geometry in
partition table and BPB of the drive(use `geometry --sync').

The above steps are required if you are going to boot DOS, because DOS
requires the right geometry in the partition table and BPB. Windows/Linux may
also require it, since the boot process could run in real-mode.


******************************************************************************
***                            Version numbering                           ***
******************************************************************************

Now we append a letter 'a', 'b', 'c' or 'p' to the version number(e.g., 0.4.5).
So the version will become 0.4.5a, 0.4.5b, 0.4.5c, 0.4.5 or 0.4.5p.

'a' - alpha test. unstable, especially when there are known bugs.
'b' - beta test. the developers think it has no bugs and want a widely testing.
'c' - release candidate.
''(nothing) - official release.
'p' - patched versions to the official release.


******************************************************************************
***                          Running User Programs                         ***
******************************************************************************

From 0.4.5 on, user programs can be developed for running under grub4dos. The
executable program file must end with the 8-byte grub4dos EXEC signature:

		0x05, 0x18, 0x05, 0x03, 0xBA, 0xA7, 0xBA, 0xBC

The executable must have no relocations, and the entry point is at the very
beginning of the file, just like a DOS .com file(but the grub4dos executable
is 32-bit).

Here is a sample file echo.c:

/*================ begin echo.c ================*/

/*
 * compile:			

gcc -nostdlib -fno-zero-initialized-in-bss -fno-function-cse -fno-jump-tables -Wl,-N -fPIE echo.c

 * disassemble:			objdump -d a.out
 * confirm no relocation:	readelf -r a.out
 * generate executable:		objcopy -O binary a.out b.out
 *
 * and then the resultant b.out will be grub4dos executable.
 */

/*
 * This is a simple ECHO command, running under grub4dos.
 */

int i = 0x66666666;	/* this is needed, see the following comment. */

/* gcc treat the following as data only if a global initialization like the
 * above line occurs.
 */

/* a valid executable file for grub4dos must end with these 8 bytes */
asm(".long 0x03051805");
asm(".long 0xBCBAA7BA");
/* thank goodness gcc will place the above 8 bytes at the end of the b.out
 * file. Do not insert any other asm lines here.
 */

int
main()
{
        void *p = &main;

	return
	/* the following line is calling the grub_sprintf function. */
	((int (*)(char *, const char *, ...))((*(int **)0x8300)[0]))
	/* the following line includes arguments passed to grub_sprintf. */
		(0, p - (*(int *)(p - 8)));
}

/*================  end  echo.c ================*/

0x8300 is a pointer to the grub4dos system funtions(API). The system_functions
variable is defined in asm.S.

More function can use in user programs:
	http://grubutils.googlecode.com/svn/trunk/src/include/grub4dos.h
note: After 2010-11-16 version of grub4dos,you can use like below.
/////////////////echo.c start///////////////////////////////////////////////
#define sprintf ((int (*)(char *, const char *, ...))((*(int **)0x8300)[0]))

#define printf(...) sprintf(NULL, __VA_ARGS__)
int i = 0x66666666;
asm(".long 0x03051805");
asm(".long 0xBCBAA7BA");
int main(char *arg,int flags)
{

	return printf("%s\n",arg);
}
/////////////////echo.c end/////////////////////////////////////////////////

******************************************************************************
***                      Map options added by Karyonix                     ***
******************************************************************************

(from boot-land.net) Karyonix's note:

map --add-mbt= option to be used with --mem. If =0 master boot track will not
	be added automatically.
map --top option to be used with --mem. map --mem will try to allocate memory
	at highest available address.
map --mem-max=, map --mem-min options to be used before map --mem. Allow user
	to manually limit range of address that map --mem can use.

safe_parse_maxint_with_suffix function parses K,M,G,T suffix after number.


******************************************************************************
***                 Graphics mode 6A: 800x600 with 16 colors               ***
******************************************************************************

Graphics mode now has 2 possibilities, one is the default 640x480 mode, and the
other is 800x600 mode.

To enter 800x600 mode, follow this way:

1. Be sure you are in console text mode. You may execute "terminal console".
2. Set graphics mode to 0x6A by using command "graphicsmode 0x6A".
3. Enter graphics mode. You may execute command "terminal graphics".

To return to 640x480 mode, follow this way:

1. Be sure you are in console text mode. You may execute "terminal console".
2. Set graphics mode to 0x12 by using command: "graphicsmode 0x12".
3. Enter graphics mode. You may execute command "terminal graphics".

****************************************************************************** 
*****			GRUB4DOS variable support			 *****
****************************************************************************** 

From now we supports variables, the same usage of MSDOS. 

commands: 
	set [/p] [/a|/A] [/l|/u] [VARIABLE=[STRING]]
	variable specifies the variable name (up to 8 characters). 
	string Specifies a string assigned to the variable (up to 512 characters.) 

SET command without parameters will display the current variables. 

with "=",if the string is empty.
	set myvar= 
Will delete the variable myvar

Show the name has been used for all variable. For example: 
	set ex_ 
Will display all variables beginning with ex_, returns 0 if no match. 

Note:	1. the same of MSDOS.
	   a full line of command will be conducted before the implementation of variable substitution. 
	2. Variable names must beginning with letter or "_".
	   Otherwise you will not be able to access your variables.
	3. See the previous description for length limit. 
	3. To reset all used variable enter command "set *"

the new command if
	if [/I] [NOT] STRING1==STRING2 [COMMAND]
	if [NOT] exist VARIABLE|FILENAME [COMMAND]

	STRING1==STRING2
	   Specifies a true condition if the specified text strings match.
	COMMAND
	   Specifies the command to carry out if the condition is met.
	/I
	   if specified, says to do case insensitive string compares.
	NOT
	   Specifies that should carry out the command only if the condition is false.

Example: 
	1. To determine whether strings are equal, and not case sensitive. 
		if /i test==%myvar% echo this is a test
	2. To determine the character is empty.
		if %myvar%#==# echo variable myvar not defined.
Usage example: 
	1. Displays a string including the variable. 
		echo myvar=%myvar% 
	2. Using a variable instead of command. 
		set print = echo 
		%print% This a test.
	3. You can use a "^" to stop extended, example 
		echo %myvar^% 
	  Or 
		echo %my^var% 
	  Will be displayed %myvar% rather than the extended character after myvar. 
Note: We only deal the ^ between the symbols %%. 

****************************************************************************** 
*****			GRUB4DOS batch scripting support		 ***** 
****************************************************************************** 

The new version supports running a batch script,It very like MS-DOS batch.
Yes!you needn't to learn a new language.

Example of a simple script: 
	========= GRUB4DOS BATCH SCRIPT START =============================== 
	!BAT #Note: The file header !BAT is necessary to identify this is a batch
	echo %0 
	echo Your type:%1 %2 %3 %4 %5 %6 %7 %8 %9 
	call :Label1 This is a test string 
	goto :label2 
	:Label1 
	echo %1 %2 %3 %4 %5 %6 %7 %8 %9 
	goto :eof 
	:Label2 
	echo end of batch script. 
	========= GRUB4DOS BATCH SCRIPT END =============================== 

Some differences: 
	1. Batch will stop when an error occurs. 
	2. Use command "exit 1",if you need to stop a running batch script.
	3. %9 refers to all the remaining parameters. 
	5. extensions
		%~d0	expands %0 to a drive letter.e.g: (hd0,0) ,()
		%~p0	expands %0 to a path only
		%~n0	expands %0 to a file name only
		%~xI	expands %0 to a file extension only
	6.In below site you can find some script.
	  http://chenall.net/post/tag/grub4dos/
