62 - Chainload syslinux from grub4dos/grub/grub2 and vice versa

hits tumblr site counter
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 \syslinuxzboot\syslinux.cfg use the command:

syslinux -f -d /boot/syslinux f: f:\syslinux.bin

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

Note: 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 menu
chainloader /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 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: Partion 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 (and copy over the grldr file):

default grub4dos

LABEL grub4dos
MENU LABEL Grub4dos
BOOT /grldr

LABEL grub4dos using ntdlr
COM32 /chain.c32
APPEND ntldr=/grldr


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\n
map --mem /ubcd/images/fdubcd.iso.gz (hd32)
map --hook
root (hd32)
chainloader (hd32)
try
title UBCD\n
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