Table of Contents
Perhaps you want to run both grub4dos (menu.lst) and syslinux (syslinux.cfg) menus from the same bootable USB drive?
Perhaps you want to boot to a linux OS via syslinux (or isolinux) but load a grub4dos menu from the menu?
Once syslinux runs, it will look for a syslinux.cfg file (which is the menu file). If your payload (e.g. linux OS) does not have one, then look for a isolinux.cfg file and copy and rename it to syslinux.cfg.
See Syslinux wiki here.
You can easily load syslinux from a grub4dos menu using rmprepusb as follows:
METHOD 1
This method simply installs grub4dos to the MBR (master boot record) and syslinux to the PBR (partition boot record).
1. Format a USB drive using RMPrepUSB as FAT32 and Boot as HDD (use Win7/bootmgr boot option though it does not really matter which one you use)
2. Use the Install Syslinux button in RMPrepUSB to install syslinux (if you want to install an earlier version then simply copy the appropriate syslinux.exe from the Syslinux folder in the RMPrepUSB folder (press F3) to the RMPrepUSB folder and overwrite the syslinux.exe that is already there)
3. Now install grub4dos to the Master Boot Record by clicking on the RMPrepUSB Install grub4dos button and say YES when prompted. Then press ENTER to copy across the grldr file when prompted.
4. Finally add an entry to your grub4dos menu.lst file (just press F4 in RMPrepUSB to load it into Notepad):
title Load syslinux menu
chainloader (hd0,0)+1
METHOD 2
An alternative is to chainload from a syslinux/isolinux bin file as follows:
1. Format a USB drive using RMPrepUSB as FAT32 and Boot as HDD (use Win7/bootmgr boot option, although it does not really matter which one you use).
2. In RMPrepUSB press F3 to open Explorer, hold down the SHIFT key and right-click on any folder (e.g. the LANG folder) and select ‘Open command windows here’. When a command prompt appears, type:
cd ..
syslinux.exe -f X: X:\syslinux.bin
where X: is the drive letter of your target USB drive. This creates the boot file syslinux.bin onto drive X: which contains the syslinux boot code. It also creates the bootfile ldlinux.sys on drive X: (the file attributes are set to Hidden, ReadOnly and System so may not be visible in Windows Explorer).
You will need to add a \syslinux.cfg file and any extra files required, such as vesamenu.c32 and any other payload files required by your cfg menu.
If you already have an isolinux.cfg file, simply rename it to syslinux.cfg.
If you want the default syslinux.cfg file to be in a different folder other than the root of the USB drive, add a -d parameter, e.g. to use f:\boot\syslinux\syslinux.cfg use the command:
syslinux -f -d /boot/syslinux f: f:\syslinux.bin
IMPORTANT: Note that the -d path uses forward slashes!
If you want to install an earlier version like version 3 – e.g. if you get ‘not a COM32R image‘ error when using syslinux version 4) then simply use the cd command to change to the appropriate version which is located in the RMPrepUSB\Syslinux folder structure.
If you already have a syslinux.bin or isolinux.bin file present in your payload OS, then you may not need to create the syslinux.bin file.
3. Now install grub4dos to the Master Boot Record by clicking on the RMPrepUSB Install grub4dos button and say YES when prompted. Then press ENTER to copy across the grldr file when prompted.
4. Finally add an entry to your grub4dos menu.lst file (just press F4 in RMPrepUSB to load menu.lst in Notepad):title Load syslinux menuchainloader /syslinux.bin
Note: If you boot to syslinux.bin and get an error message about ‘no UI or DEFAULT’, it means either it cannot find the syslinux.cfg file or the syslinux.cfg file does not contain a ‘default’ statement.
Make sure that a syslinux.cfg file is present. If you only have an isolinux.cfg file, then simply rename it to syslinux.cfg.
You can use the menu below to get back to grub4dos (see ‘Run grub4dos from Syslinux’).
Error 43: The BPB hidden_sectors should not be zero for a hard-disk partition boot sector
#Error 43: The BPB hidden_sectors should not be zero for a hard-disk partition boot sector #See Wonko's post at http://reboot.pro/topic/16429-easy2boot-development-discussion/page-30#entry185771 # This error may be found when attempting to chainload to a partition - e.g. chainloader (hd0,1)+1 # The following code assumes partition 4 is empty/unused set BOOTPTN=(hd0,1) debug normal parttype (hd0,3) | set check= set check=%check:~-5,4% #create new ptn4 (also fixes up the BPB hidden sectors in %BOOTPTN%) if %check%==0x00 partnew (hd0,3) 0x00 %BOOTPTN% # remove new partition entry if %check%==0x00 partnew (hd0,3) 0 0 0 0 if NOT %check%==0x00 echo ERROR: Partition Table entry 4 already exists! && pause --wait=3 && configfile /menu.lst chainloader %BOOTPTN%+0x50 boot
START ISOLINUX FROM GRUB4DOS
If you have some linux files on your CD and it has an isolinux folder, then to run isolinux from a grub4dos menu, try
title Run abc linux
chainloader /boot/isolinux/isolinux.bin
If you see the error below…
Cannot chainload ISOLINUX from a non-CDROM device
chainloader /isolinux.bin
Error 13: Invalid or unsupported executable format
with a USB drive, try using syslinux.bin and Method 2 above.
isolinux is for CD drives only.
RUN GRUB4DOS FROM SYSLINUX
If you wish to boot to syslinux and then from the syslinux.cfg menu you want to run grub4dos, simply use RMPrepUSB to install syslinux and use the following syslinux menu entry in your syslinux.cfg file.
default grub4dos
LABEL grub4dos
MENU LABEL Grub4dos
kernel /grub.exe
You also need to make sure that you copy over the grub.exe file from the grub4dos (featured) download to the root of the USB drive.
You can also specify the menu file using an additional line of
APPEND --config-file=/abc/yyy.txt
or even specify grub4dos commands, for example:
APPEND --config-file="map /images/abc.iso (0xff);map --hook;chainloader (0xff)"
Or instead, you can try one of these (copy over the grldr file and use the correct path to chain.c32 file):
LABEL grub4dos using ntdlr
COM32 /chain.c32
APPEND ntldr=/grldr
LABEL use BOOT command
BOOT /grldr
LABEL grub4dos
COM32 /DLC1/Boot/chain.c32 ntldr=/grldr hd0 1
LABEL grub4dos using ntdlr - get grub4dos to look for menu.lst on 2nd PRIMARY partition first (2nd ptn is root)
COM32 /chain.c32
APPEND ntldr=/grldr hd0 2
LABEL grub4dos using ntdlr - get grub4dos to look for menu.lst on 2nd LOGICAL partition first (2nd log ptn is root)
COM32 /chain.c32
APPEND ntldr=/grldr hd0 6
LABEL grub4dos using ntdlr - get grub4dos to look for menu.lst on 2nd partition of 2nd HDD first, then swap hd0 with hd1
COM32 /chain.c32
APPEND ntldr=/grldr hd1 2 swap
To boot to Windows Vista/7/8/WinPE v2,3,4 etc. which is located on a 2nd partition of the boot drive, try this (no menu.lst is needed)
default Win8ToGo
LABEL Win8ToGo
MENU LABEL Win8ToGo
KERNEL /grub.exe
APPEND --config-file="root (hd0,1);chainloader /bootmgr"
DOS based images
If you are loading one ISO in grub4dos and then chaining to syslinux which loads another 2nd ISO and then find that the DOS payload does not see the first grub4dos ISO (“no CD found!“), then this is probably due to mixing grub4dos map commands with syslinux memdisk. In this case try changing your grub4dos menu so that it uses memdisk to load an ISO file rather than a map command – e.g.
Instead of
title UBCD
map --mem /ubcd/images/fdubcd.iso.gz (hd32)
map --hook
root (hd32)
chainloader (hd32)
try
title UBCD
kernel /memdisk iso
initrd (bd)/ubcd/images/fdubcd.iso.gz
You will need to add the file memdisk to your boot device.
CONVERT A SYSLINUX.CFG FILE TO A MENU.LST FILE
This is taken from a post by Wonko the Sane (aka jaclaz)
Example syslinux/isolinux entry
label parted magic
kernel images/pmagic/bzImage
append noapic initrd=images/pmagic/initramfs root=/dev/ram0 init=/linuxrc ramdisk_size=100000
When converted to grub4dos we get:
title parted magic
kernel /images/pmagic/bzImage noapic root=/dev/ram0 init=/linuxrc ramdisk_size=100000
initrd /images/pmagic/initramfs
label becomes title
The initrd command must be used to specify the initial ram filesystem loader file.
kernel remains kernel followed by the path to the kernel file
There is no direct equivalent to the append command in grub4dos, because grub4dos it parses ANYTHING after the kernel file, as parameters to be passed to the Linux kernel (same thing append does) but you need to remove the initrd parameter from the kernel parameter list.
After a grub4dos command there should be a space (and NOT an = sign, though it’s parser allows it).
A file or device in grub4dos is always a “qualified” path, when you write /images/pmagic/bzImage you are actually writing ()/images/pmagic/bzImage or in “pseudocode” <current root>/images/pmagic/bzImage. Say that your current root is (pd), then by writing /images/pmagic/bzImage you are actually writing (pd)/images/pmagic/bzImage and of course if you omit the leading slash what you get makes NO sense as (pd)images/pmagic/bzImage
WARNING: If the menu.lst is not working correctly, make sure you have the correct <cr><lf> characters between each line. If you have use Windows cut-and-paste to copy lines from a web page or from a syslinux or isolinux menu, you can often find that you have invisible characters in your menu.lst file. It may appear OK in Notepad but not in Notepad++. Verify that your menu.lst commands are OK, by running grub4dos and highlighting the menu entry you want to look at, then press e to edit the menu entry – check that the menu lines are correct and identical to the lines in your menu.lst file. This has happened to me several times when copying from a linux file to a standard text file – the commands looked valid but they were reporting errors when executed!
RUN DOS FROM SYSLINUX
Assumes chain.c32 is in the root…
default freedos
prompt 1
LABEL freedos
KERNEL /chain.c32
APPEND freedos=/kernel.sys
LABEL msdos
KERNEL /chain.c32 APPEND msdos=/io.sys
Some versions of MS-DOS may not work using this command. It is always better to use a MS-DOS image file and boot from that if possible, or use a PBR boot sector (abc.bss) or try using grub4dos…
LABEL dos via memdisk
# copy the memdisk file to the root
KERNEL memdisk
APPEND initrd=dos.ima
LABEL Boot via grub4dos
# copy the grub.exe file to the root
KERNEL /grub.exe
APPEND --config-file="geometry --bios --sync;chainloader /io.sys"
LABEL DOS via boot sector (most reliable)
# NOTE: It is VERY IMPORTANT that the boot sector file extension is .BSS which tells syslinux to patch DOS superblock - otherwise it won't boot properly!!!
KERNEL MSDOS.BSS
# Also try the BSS command if the kernel command fails…
BSS MSDOS.BSS
Note: You can create a .BSS file using the RMPrepUSB Drive->File function. Ensure that the drive boots correctly (to IO.SYS or NTLDR or KERNEL.SYS or whatever) and check that the Partition Boot Record (PBR) is correct by using the Drive Info button and entering P1 for the first sector of the partition – the sector’s contents should have the name of the boot file in it (usually near the end – e.g. IO.SYS). To make a .BSS file, use the Drive->File button and then choose a name for the file (e.g. DOS.BSS), start=P1, length=1SEC, File start byte=0.
LOAD GRUB4DOS OR BOOTMGR FROM GRUB
To boot from the grldr file
search --file /grldr --set=root
insmod ntldr
ntldr /grldr
Use ntldr /bootmgr to boot to Windows.
To load grub4dos from grub and boot from partition 1 automatically, try (using grub4dos 0.4.6a 2022 version):
set opt='chainloader (hd0,0)+1 ;; boot' linux16 ($root)/grub4dos/grub.exe --config-file=$opt boot
Another example:
if [ "${grub_platform}_${grub_cpu}" = "pc_i386" ]; then menuentry "Run Medicat VHD using grub4dos (Legacy)" --class=custom { set root=hd0,1 set mycmd="map --heads=0 --sectors-per-track=0 (hd0,0)/Medicat.img (hd) ;; map --hook ;; rootnoverify (hd-1) ;; chainloader +1 ;; boot"; # line below must not exceed 255 chars when expanded linux /grub.exe --config-file=${mycmd}; boot } fi
See here for details.
Note that there is a line length limitation of about 255 characters in total. For longer commands you can use a menu.lst file, e.g.
linux ($root)/grub4dos/grub.exe --config-file=configfile (hd0,0)/menu.lst initrd (rd)
LOAD GRUB4DOS FROM GRUB2
To load grub.exe from partition 1
menuentry "Run grub4dos"{
set root='(hd0,1)'
linux /grub.exe
}
or run grub4dos commands:
menuentry "Boot mycd.iso" {
set opts='map /test/mycd.iso (0xff); map --hook; chainloader (0xff);'
linux /boot/grub/grub4dos.exe --config-file=${opts}
}
Note that grub2 numbers partitions starting from 1 but grub4dos numbers partitions from 0 (e.g. (hd0,1) in grub2 == (hd0,0) in grub4dos).
Also paths or filenames with spaces must be converted to grub4dos paths by adding the \ character before each space, e.g. /A B/t.iso becomes /A\ B/t.iso for a valid grub4dos path.
It is possible to convert a grub2 path and device name to a grub4dos path using a grub4dos batch file. Here is an example (legacy only):
if [ "${grub_platform}_${grub_cpu}" = "pc_i386" ]; then menuentry "Test iso with spaces \A B\t.iso" --class=custom { set "ISO=(msdos0,1)/A B/t.iso" set cmd="set P=${ISO}; call /grubpath.g4b; find --set-root %P%; map %P% (0xff); map --hook; chainloader (0xff); boot" linux16 (hd0,1)/grub.exe --config-file=${cmd}; } fi
The grubpath.g4b file will convert a grub2 device name, partition number and path with spaces held in the P variable, to the correct format for grub4dos commands. The file grubpath.g4b can be found in the Easy2Boot project download in the \_ISO\e2b\grub folder (E2B v2.20 or later).
To boot from the grldr file use:
search --file /grldr --set=root
insmod ntldr
ntldr /grldr
Pass parameters from grub2
The example above allows you to pass parameters to grub.exe from grub2, however if you do not want to use grub.exe or want to load grub4dos for EFI (grub4efi) from grub2 and pass parameters to grub4dos, you can use the save_env grub2 command to save any variable to a small 1024-byte file (typically called grubenv).
In grub2, save one or more grub2 parameters using the save_env command, e.g.
save_env -f (hd0,1)/ventoy/grubenv vt_param
This will save the vt_param name and value to the grubenv file on the first partition.
Now you can load grub4dos or grub4efi from grub2 by any method you prefer – e.g. chainloader “(${bootdev},1)/grub4efi/BOOTX64.EFI”
In grub4dos/grub4efi, you can then parse the grubenv file to obtain any saved parameter by using a batch file, e.g.
# get the variable vt_param into the grub4dos variable P (and grub4dos variable vt_param)
/grubenv.g4b vt_param "(bd)/ventoy/grubenv"
If the parameter contained a grub2 path, it will need to be converted to a grub4dos-compatible path, we can do this by using another batch file, e.g.
# convert path in P to a valid grub4dos path - reduce partition number by 1, insert \ before all spaces
/grubpath.g4b
You can find examples of these two batch files and a blank grubenv 1024-byte file in the Easy2Boot download files (under \_ISO\e2b\grub folder).
LOAD GRUB2 FROM GRUB4DOS
kernel /g2ldr
OR
Find the core.img file…
title Boot grub2 from partition 3 \n Boot to core.img
root (hd0,2)
if exist /boot/grub/i386-pc/core.img kernel /boot/grub/i386-pc/core.img && boot
if exist /boot/grub/core.img kernel /boot/grub/core.img && boot
if exist /grub2/core.img kernel /grub2/core.img && boot
if exist /boot/grub2/i386-pc/core.img kernel /boot/grub2/i386-pc/core.img && boot
# grub - e.g. bitdefender
if exist /boot/grubi386.pc kernel /boot/grubi386.pc && boot
To pass one or more parameters to grub2, you could write entries into a grubenv file before loading grub2 and then use the load_env command in grub2 to get the variables and values from the grubenv file (see section above). Note that the length of the grubenv file must not be changed.