62 - Chainload syslinux from grub4dos/grub/grub2 and vice versa
hits
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.binNote: 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 normalStart 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 linuxchainloader /boot/isolinux/isolinux.binIf 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 grub4dosLABEL grub4dosMENU LABEL Grub4doskernel /grub.exeYou 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 ntdlrCOM32 /chain.c32APPEND ntldr=/grldrLABEL grub4dosCOM32 /DLC1/Boot/chain.c32 ntldr=/grldr hd0 1LABEL grub4dos using ntdlr - get grub4dos to look for menu.lst on 2nd PRIMARY partition first (2nd ptn is root)COM32 /chain.c32APPEND ntldr=/grldr hd0 2LABEL grub4dos using ntdlr - get grub4dos to look for menu.lst on 2nd LOGICAL partition first (2nd log ptn is root)COM32 /chain.c32APPEND ntldr=/grldr hd0 6LABEL grub4dos using ntdlr - get grub4dos to look for menu.lst on 2nd partition of 2nd HDD first, then swap hd0 with hd1COM32 /chain.c32APPEND ntldr=/grldr hd1 2 swapTo 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 Win8ToGoLABEL Win8ToGoMENU LABEL Win8ToGoKERNEL /grub.exeAPPEND --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\nmap --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.gzYou 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 magickernel images/pmagic/bzImageappend noapic initrd=images/pmagic/initramfs root=/dev/ram0 init=/linuxrc ramdisk_size=100000When converted to grub4dos we get:
title parted magickernel /images/pmagic/bzImage noapic root=/dev/ram0 init=/linuxrc ramdisk_size=100000initrd /images/pmagic/initramfslabel 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.sysSome 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 rootKERNEL memdiskAPPEND 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.BSSNote: 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 - it 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=rootinsmod ntldrntldr /grldrUse ntldr /bootmgr to boot to Windows.
To load grub4dos from grub and boot from partition 1 automatically, try
set opt='chainloader (hd0,1)+1; boot'linux16 ($root)/grub4dos/grub.exe --config-file=$optSee here for details.
Load grub4dos from grub2
To load grub.exe from the 2nd partition
menuentry "Run grub4dos"{ set root='(hd0,1)' linux /grub.exe}or try
menuentry "Boot mycd.iso" { set opts='map /test/mycd.iso (0xff); map --hook; chainloader (0xff);' linux /boot/grub/grub4dos.exe --config-file=${opts}}Load grub2 from grub4dos
kernel /g2ldrOR
Find the core.img file...
title Boot grub2 from partition 3 \n Boot to core.imgroot (hd0,2)if exist /boot/grub/i386-pc/core.img kernel /boot/grub/i386-pc/core.img && bootif exist /boot/grub/core.img kernel /boot/grub/core.img && bootif exist /grub2/core.img kernel /grub2/core.img && bootif exist /boot/grub2/i386-pc/core.img kernel /boot/grub2/i386-pc/core.img && boot# grub - e.g. bitdefenderif exist /boot/grubi386.pc kernel /boot/grubi386.pc && boot