Tuesday, September 30, 2008

Grub chainloads syslinux and back

Some introductory considerations:
  • Booting from an USB device with GRUB is quite easy (here and there..).
  • Booting from an USB device with syslinux is also quite easy (here).
  • Chainloading GRUB from syslinux seems not to be possible without tricks: syslinux boots from the boot record and sees its own partition only, thus GRUB should reside on the same partition and be packaged as an "xxxx.bin" file to be passed to syslinux via the "kernel /path_to/xxxx.bin" directive. Never tried and I'll never too, until I'll not find somehow useful.
  • Chainloading syslinux from GRUB seems not to be possible without a patch. I don't know about GRUB2. This could be useful for multi-booting (syslinux-based) partitions.
  • Chainloading GRUB4dos from syslinux is possible, because "grub.exe" can reside on the same FAT partition where syslinux is. Only an entry in "syslinux.cfg" with the "kernel /path_to/grub.exe" directive is needed
  • Chainloading syslinux from GRUB4dos (on the same partition) should be possible because GRUB4dos is more flexible than GRUB, but I didn't manage to make it work, even if I tried all combinations of paths, mappings and syntaxes, like here.
  • Chainloading syslinux from GRUB4dos (on different partitions) is possible. I managed it through the mapping, explained (again) here. It solves some problems in multi-booting usb devices.

To load syslinux (on different partitions) from GRUB4dos, my steps were:
  1. take a partitioned device;
  2. take the first primary partition, formatted as FAT;
  3. get GRUB4dos and install it on the master boot record of that partition;
  4. get syslinux and install it on (some of) the other partitions;
  5. edit "menu.lst" in the proper grub4dos folder in order to chainload syslinux with the entry:

    title -your entry title-
    map (hdx,y)+1 (fd0)
    map --hook
    root (fd0)
    chainloader +1

    where x and y identify the syslinux-based partition in the usual grub-style form.
    I tried to map the syslinux-based partition to an "hd_" device instead of "fd0", but no success: I don't know why.