Grub4dos Example Menus


The menu code below cannot just be cut and pasted into one large menu.lst file!

You need to just take the bits that you need!

Testing

  • Use a path and filename that does not contain spaces - e.g. ubuntu_x64_test.iso
  • Test on a real system (not just a Virtual Machine)
  • Test on 32-bit and 64-bit systems
  • Test using a USB 2.0 port on an old system (some OS's don't have modern USB controller drivers, e.g .Win7)
  • Test using a non-UASP USB device (some OS's don't have UASP drivers)
  • Test on a FAT32 formatted USB drive if an NTFS drive does not work
  • Test using a Removable-type Flash drive as well as a Fixed-type USB drive


EXAMPLES

The grub4dos menus and code snippets below should be copied into your own menu - DO NOT JUST COPY THIS WHOLE PAGE!

ALWAYS TEST USING A FILENAME THAT DOES NOT CONTAIN ANY SPACES!

NOTE: Kernel parameter values (xxxxx=yyyyy) cannot cope with spaces. Ensure that the ISO filename and path does not contain spaces if you are using a kernel parameter such as fromiso= or iso-scan/filename=. Usually 'escaping' the filename with quotes or using \x20 does not work for the ISO filename.


Please search this site for the relevant tutorials!

#check version of grub4dos is later than 01-02-2012
checkrange 20120201:-1 read 0x8278 || pause --wait=3 Please use grub4dos-0.4.5c-2012-02-01 or later! && exit 1

#reset key map
setkey

#change key map for UK keyboard
setkey
setkey at doublequote
setkey doublequote at
setkey tilde bar
setkey numbersign backslash

#French
setkey
setkey less backquote
setkey greater tilde
setkey ampersand 1
setkey 1 exclam
setkey tilde 2
setkey 2 at
setkey doublequote 3
setkey 3 numbersign
setkey quote 4
setkey 4 dollar
setkey parenleft 5
setkey 5 percent
setkey minus 6
setkey 6 caret
setkey backquote 7
setkey 7 ampersand
setkey underscore 8
setkey 8 asterisk
setkey backslash 9
setkey 9 parenleft
setkey at 0
setkey 0 parenright
setkey parenright minus
setkey numbersign underscore
:: no change for equal
:: no change for plus
setkey a q
setkey A Q
setkey z w
setkey Z W
setkey caret bracketleft
:: no equivalent for diaresis => we keep the US braceleft
setkey dollar bracketright
:: no equivalent for pound => we keep the US braceright
setkey q a
setkey Q A
setkey m semicolon
setkey M colon
setkey bracketleft quote
setkey percent doublequote
setkey asterisk backslash
setkey bracketright bar
setkey w z
setkey W Z
setkey comma m
setkey question M
setkey semicolon comma
setkey period less
setkey colon period
setkey slash greater
setkey exclam slash
setkey bar question

#Japan 106
setkey
setkey at bracketleft
setkey doublequote at
setkey ampersand caret
setkey quote ampersand
setkey parenleft asterisk
setkey parenright parenleft
setkey underscore parenright
setkey equal underscore
setkey plus colon
setkey colon quote
setkey asterisk doublequote
setkey bracketleft bracketright
setkey braceleft braceright
setkey bracketright backslash
setkey braceright bar
setkey backslash backquote
setkey tilde plus
setkey caret equal
setkey backquote braceleft
setkey bar tilde


# to set a german keyboard use these setkey commands before the first title command
setkey
setkey yz
setkey zy
setkey YZ
setkey ZY
setkey equal parenright
setkey parenright parenleft
setkey parenleft asterisk
setkey doublequote at
setkey plus bracket right
setkey minus slash
setkey slash ampersand
setkey ampersand percent
setkey percent caret
setkey underscore question
setkey question underscore
setkey semicolon less
setkey less number sign
setkey number sign backslash
setkey colon greater
setkey greater bar
setkey asterisk braceright

# set AZERTY ketyboard
setkey
setkey a q
setkey A Q
setkey z w
setkey Z W
setkey q a
setkey Q A
setkey m semicolon
setkey M colon
setkey w z
setkey W Z
setkey comma m
setkey question M
setkey semicolon comma
setkey period less
setkey colon period
setkey slash greater
setkey exclam slash
setkey dollar bracketright
setkey asterisk backslash
setkey percent doublequote
setkey ampersand 1
setkey 1 exclam
setkey tilde 2
setkey 2 at
setkey doublequote 3
setkey 3 numbersign
setkey quote 4
setkey 4 dollar
setkey parenleft 5
setkey 5 percent
setkey minus 6
setkey 6 caret
setkey backquote 7
setkey 7 ampersand
setkey underscore 8
setkey 8 asterisk
setkey caret 9
setkey 9 parenleft
setkey at 0
setkey 0 parenright
setkey parenright minus
setkey less backquote
setkey greater tilde
setkey numbersign braceright
setkey backslash question
setkey bracketright braceleft
setkey braceleft quote
setkey braceright underscore

#QWERTZ keyboard
setkey
setkey y z
setkey z y
setkey Y Z
setkey Z Y
setkey equal parenright
setkey parenright parenleft
setkey parenleft asterisk
setkey doublequote at
setkey backquote equal
setkey plus bracketright
setkey minus slash
setkey slash ampersand
setkey ampersand percent
setkey percent caret
setkey underscore question
setkey question underscore
setkey semicolon less
setkey less numbersign
setkey numbersign backslash
setkey colon greater
setkey greater bar
setkey asterisk braceright
setkey caret backquote
setkey backslash minus



# ensure not in debug=2 mode or gfxmenu will need two key presses!
debug 1
gfxmenu /message
color black/cyan yellow/cyan
timeout 1
default 0
# line below will ensure the gfxmenu is always loaded even after an error
configfile (bd)/menu.lst

# if booting from a USB Flash drive get the UUID like this
debug 1
uuid (bd) > (md)0x220+1
cat --skip=18 --length=9 (md)0x220+1 | set UUID=
# if booting from HDD use --length=16
echo UUID of boot device is %UUID%

# Ignore boot device and boot to Windows XP, Vista, 7 or 8 from the internal hard disk
# This works by mapping the boot device (bd) which may have bootmgr or ntldr on it, to a virtual memory drive so that files on it are not found by the find command
title Boot to Windows from an internal hard disk
map --mem (md)+8 (bd)
map --hook
find --set-root --ignore-floppies --ignore-cd /bootmgr || find --set-root --ignore-floppies --ignore-cd /ntldr
map (bd) (bd)
map --rehook
chainloader /bootmgr || chainloader /ntldr


#This entry sends an ESC character which can be used to exit from the GFXMenu back to the grub4dos text menu (or the user can just press ESC instead)
#The file esc.txt must exist and contain the ESC character (0x1b or 27 or 033 octal) - the esc.txt file is in Beta Downloads section if you want it!
title grub4dos menu
cat /esc.txt && clear

title List partitions
clear
cat (hd0,0)+1 > (md)800+1 && parttype (hd0,0) && echo Contents of (hd0,0): && ls (hd0,0)/ && echo && echo --------
cat (hd0,1)+1 > (md)800+1 && parttype (hd0,1) && echo Contents of (hd0,1): && ls (hd0,1)/ && echo && echo --------
cat (hd0,2)+1 > (md)800+1 && parttype (hd0,2) && echo Contents of (hd0,2): && ls (hd0,2)/ && echo && echo --------
cat (hd0,3)+1 > (md)800+1 && parttype (hd0,3) && echo Contents of (hd0,3): && ls (hd0,3)/ && echo && echo --------
cat (hd0,4)+1 > (md)800+1 && parttype (hd0,4) && echo Contents of (hd0,4): && ls (hd0,4)/ && echo && echo --------
cat (hd1,0)+1 > (md)800+1 && parttype (hd1,0) && echo Contents of (hd1,0): && ls (hd1,0)/ && echo && echo --------
cat (hd1,1)+1 > (md)800+1 && parttype (hd1,1) && echo Contents of (hd1,1): && ls (hd1,1)/ && echo && echo --------
cat (hd1,2)+1 > (md)800+1 && parttype (hd1,2) && echo Contents of (hd1,2): && ls (hd1,2)/ && echo && echo --------
cat (hd1,3)+1 > (md)800+1 && parttype (hd1,3) && echo Contents of (hd1,3): && ls (hd1,3)/ && echo && echo --------
cat (hd1,4)+1 > (md)800+1 && parttype (hd1,4) && echo Contents of (hd1,4): && ls (hd1,4)/ && echo && echo --------
echo
pause --wait=10 Please check available partitions...
configfile (bd)/menu.lst

title Reboot
reboot

title Switch Off
halt

#hotkey and autonumber example
color white/blue
write --bytes=2 0x8274 0x2001
## run hotkey once to enable hotkey.
/hotkey
## show this menu only if /ntldr can be found
iftitle [find /ntldr] ^Ctrl+F1 Press Ctrl+F1 to boot /ntldr
find --set-root /ntldr
chainloader /ntldr


# Check this CD/USB drive is not too old - see Tutorial #71 for details
# Usage: /checkdate.g4b <Release Year> <Release Month> <Release DayOfMonth> <ExpiresInDays> [<SILENT>]
/checkdate.g4b 2012 12 3 2
pause
if NOT "%CHECKDATE%"=="OK" reboot

#Boot using the original backup MBR sector (copied to LBA1 by grub4dos on install)
#This will boot the system as it would before grub4dos was installed
title Normal Windows Boot
rootnoverify (hd0)
chainloader (hd0)1+1

#this assumes you have booted from a USB drive and you want to boot from the hard disk
title Boot from 1st Hard Disk \nBoot from MBR of first hard disk
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
chainloader (hd0)+1
rootnoverify (hd0)


title FreeDOS
find --set-root /kernel.sys
chainloader /kernel.sys

title MSDOS
find --set-root /io.sys
chainloader /io.sys

title FreeDOS (AS HDD)
map (hd0) (hd1)
map (hd1) (hd0)
map --hook