Isohybrid

From Syslinux Wiki
Jump to: navigation, search

ISO 9660 filesystems created by the mkisofs command as described in the ISOLINUX article will boot via BIOS firmware, but only from optical media like CD, DVD, or BD.

The isohybrid feature enhances such filesystems by a Master Boot Record (MBR) for booting via BIOS from disk storage devices like USB flash drives.

ISOLINUX provides two alternative programs to apply this feature on image files or block devices with ISO 9660 filesystems:

  • isohybrid.pl needs a Perl interpreter and is supposed to be widely portable.
  • isohybrid from utils/isohybrid.c needs to be compiled once for a particular operating system and hardware architecture; then it is usable without other preconditions.

There is also an additional isohybrid feature for UEFI.

Options

Usage: isohybrid [options] filename.iso
 Option Valid
Range
Default
Value
Meaning
-h # [1, 255] (i) 64 Number of default geometry heads
-s # [1, 63] (i) 32 Number of default geometry sectors
-entry # [1, 4] 1 Specify partition entry number
-offset # [0, 64] 0 Specify partition offset
-type # [0, 255] 0x17
"Windows hidden IFS"
Specify partition type
-id # [0, 0xffffffff] (random) Specify MBR ID
-forcehd0     Always assume we are loaded as disk ID 0
-ctrlhd0     Assume disk ID 0 if the Ctrl key is pressed
-partok     Allow booting from within a partition

(i) See also Hardware_Compatibility#USB-Geometry.

BIOS

Both isohybrid programs contain MBR code matching the same version of the ISOLINUX bootloader file, "isolinux.bin", therefore the isohybrid program from the same Syslinux installation that provided this bootloader file for the ISO 9660 production should be used.

The basic usage is simple. Create a bootable ISO 9660 image file named "output.iso" by either mkisofs, genisoimage, or xorriso and then treat it by:

 isohybrid output.iso

Both isohybrid programs can take expert options, listed by:

 isohybrid -?

Alternatively, the ISO 9660 production program "xorriso" can enhance its results by isohybrid, if an MBR template file from the local Syslinux installation is provided. The names of these files match the "isohdp[fp]x*.bin" pattern and are to be found in Syslinux under the "./[bios/]mbr" directory or installed as, for example, "/usr/lib/syslinux/isohdpfx.bin".

 xorriso -as mkisofs \
  -o output.iso \
  -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin \
  -c isolinux/boot.cat \
  -b isolinux/isolinux.bin \
   -no-emul-boot -boot-load-size 4 -boot-info-table \
  CD_root

The resulting ISO image needs no further treatment by isohybrid tools.

MBR selection

Syslinux provides variations of the MBR code, contained in its isohybrid programs. The options "--forcehd0", "--ctrlhd0", "--partok" may be used to choose one of the non-default flavors.

When booting a "healthy" BIOS:

isohybrid MBR selection:
Option MBR File Comments
no options (default) isohdpfx.bin Boot from base device
--forcehd0 isohdpfx_f.bin Boot from BIOS disk 0x80
--ctrlhd0 isohdpfx_c.bin If the Ctrl key is held during boot time,

  then boot from BIOS disk 0x80

--partok isohdppx.bin Boot from a partition device

  (e.g. /dev/sdx1 rather than /dev/sdx)

--partok --forcehd0 isohdppx_f.bin Boot from a partition of BIOS disk 0x80
--partok --ctrlhd0 isohdppx_c.bin If the Ctrl key is held during boot time,

  then boot from BIOS disk 0x80;
otherwise, boot from a partition device.

UEFI

If the ISO 9660 image includes a UEFI bootloader capable of booting optical media in UEFI mode, then the isohybrid command can also achieve an equivalent result for UEFI systems just as described for BIOS ones.

The additional isohybrid feature for UEFI adds a partition to the MBR partition table pointing to the same file in the ISO 9660 filesystem as does the El Torito catalog entry for EFI. This file contains a FAT filesystem with boot equipment from which the UEFI firmware will be able to start the desired operating system. Furthermore, isohybrid for UEFI creates a GUID Partition Table (GPT) with a partition pointing to that file.

It can be brought into the ISO 9660 filesystem as second boot image with options "-eltorito-alt-boot" and "-e" by Fedora's variant of genisoimage, or by xorriso:

genisoimage \
 -o output.iso \
 -c isolinux/boot.cat \
 -b isolinux/isolinux.bin \
  -no-emul-boot -boot-load-size 4 -boot-info-table \
 -eltorito-alt-boot \
 -e isolinux/efiboot.img \
  -no-emul-boot \
 CD_root

With mkisofs, the equivalent command is:

mkisofs \
 -o output.iso \
 -c isolinux/boot.cat \
 -b isolinux/isolinux.bin \
  -no-emul-boot -boot-load-size 4 -boot-info-table \
 -eltorito-alt-boot \
 -eltorito-platform 0xEF -eltorito-boot isolinux/efiboot.img \
  -no-emul-boot \
 CD_root

The isohybrid tool compiled from utils/isohybrid.c has an option to add a suitable MBR partition and GPT to such a UEFI bootable filesystem:

 isohybrid --uefi output.iso

The ISO 9660 filesystem is then supposed to boot from optical media and from disk storage via BIOS and via UEFI. Unfortunately, there seem to be some UEFI implementations that boot from MBR and fail to boot if GPT is present. Therefore, some Linux distributions have special ISO images for amd64 containing only BIOS equipment.

xorriso can add the GPT equipment by its "-isohybrid-gpt-basdat" option:

 xorriso -as mkisofs \
  -o output.iso \
  -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin \
  -c isolinux/boot.cat \
  -b isolinux/isolinux.bin \
   -no-emul-boot -boot-load-size 4 -boot-info-table \
  -eltorito-alt-boot \
  -e isolinux/efiboot.img \
   -no-emul-boot \
   -isohybrid-gpt-basdat \
  CD_root

Again, the resulting ISO image file needs no further treatment by isohybrid tools.

Copying onto USB stick by shell commands

As any other ISO image, the content of an isohybrid image can be burned to optical media, or alternatively it can be extracted onto a USB stick which can be eventually booted by SYSLINUX.

The advantage of an isohybrid image is that it can also be easily "burned" (as opposed to extracting its content) onto storage media such as USB sticks. Such storage media then can boot the system in a similar way as the read-only optical media.

The properly equipped ISO image can be put on a USB flash drive. Unless option "--partok" is used, it has to be copied to the base disk device so that it overwrites the partition table. Partition editors may then be used, in order to make the remaining storage capacity available as additional partition for a read-write filesystem.

The following procedure is for ISO images prepared without "--partok".

Verify device address or make a backup

The main problem on a Linux system is that you need superuser power to overwrite the whole USB stick, and that this power suffices to also spoil the content of your hard disk.

So first verify that the device file address really leads to the intended device (e.g. by reading a few megabytes and watching it blink). If the USB stick is supposed to be Linux device "/dev/sdb":

 umount /dev/sdb
 dd if=/dev/sdb of=/dev/null bs=1024 count=100000

or by making a backup of its complete content in a compressed disk file :

 umount /dev/sdb
 dd if=/dev/sdb | gzip >"$HOME"/red_usb_stick.gz

Write to USB stick

Once you are convinced that this is the right device file address, copy the ISO image onto the USB stick by:

 dd if=output.iso bs=2048 of=/dev/sdb

Eventually restore backup

To later restore the original content of the USB stick, take the same care to really use the correct address and then:

 dd if="$HOME"/red_usb_stick.gz | gunzip >/dev/sdb

Images prepared with --partok

ISO images that were prepared by "--partok" (i.e. with "isohdppx*.bin") have to be dd' to a partition device (e.g. "/dev/sdb1" rather than "/dev/sdb"). Such an ISO partition may then be booted by chainloading or by a suitable MBR at the start of the base disk device.

Some reports indicate that "isohybrid --partok" images can be chainloaded by GRUB, but only from primary MBR partitions. Logical MBR partitions and GPT partitions are reported not to work in this combination.

See Also