Difference between revisions of "Isohybrid"

From Syslinux Wiki
Jump to: navigation, search
(Removed link to article Mbr)
m (Minor Rewording. Wiki formatting.)
Line 38: Line 38:
 
The ISO 9660 production program xorriso can enhance its results
 
The ISO 9660 production program xorriso can enhance its results
 
by isohybrid, if an MBR template file from the local SYSLINUX
 
by isohybrid, if an MBR template file from the local SYSLINUX
installation is provided. The names of these files match the
+
installation is provided.  
pattern isohdp[fp]x*.bin and are to find in SYSLINUX directory ./mbr
+
The names of these files match the {{nowrap|''isohdp[fp]x*.bin''}} pattern and are to be found in Syslinux under the {{nowrap|<tt>./<nowiki>[bios/]</nowiki>mbr</tt>}} directory or installed as e.g. /usr/lib/syslinux/isohdpfx.bin.
or installed as e.g. /usr/lib/syslinux/isohdpfx.bin.
+
 
 
<pre>
 
<pre>
 
xorriso -as mkisofs \
 
xorriso -as mkisofs \

Revision as of 02:48, 14 August 2014

ISO 9660 filesystems which are created by the mkisofs command in the article about ISOLINUX will boot via BIOS or UEFI firmware only from optical media like CD, DVD, or BD. (This includes virtual BIOS and virtual CD-ROM.)

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 programs which can do this in 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.

Meanwhile there is an additional isohybrid feature for UEFI.

BIOS

Both isohybrid programs contain MBR code which has to match the version of the ISOLINUX file isolinux.bin. So always use the program from the same SYSLINUX installation which provided this file for the ISO 9660 production.

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

isohybrid output.iso

Both programs take expert options which are listed by

isohybrid -?

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 e.g. /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 six variations of the MBR code, which are contained in its isohybrid programs. The options --forcehd0, --ctrlhd0, --partok may be used to choose one of the non-default flavors.

  • without these options, isohdpfx.bin is chosen. It is for booting from the base device by a healthy BIOS.
  • --forcehd0 chooses isohdpfx_f.bin, which forces booting from BIOS drive 0x80.
  • --ctrlhd0 chooses isohdpfx_c.bin, which forces BIOS drive 0x80 only if the Ctrl key is held during boot.
  • --partok chooses isohdppx.bin, which is for booting from a device partition by a healthy BIOS.
  • --partok --forcehd0 chooses isohdppx_f.bin, for booting from a partition of BIOS disk 0x80.
  • --partok --ctrlhd0 chooses isohdppx_c.bin, for booting from a partition either of disk 0x80 or of the BIOS detected disk, depending on whether the Ctrl key is held during boot.

UEFI

The additional isohybrid feature for UEFI adds a partition to the MBR partition table which points 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. Further isohybrid for UEFI creates a GUID Partition Table (GPT) with a partition which points 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 replace

   -e isolinux/efiboot.img \

by

  -eltorito-platform 0xEF -eltorito-boot isolinux/efiboot.img \

The isohybrid tool compiled from utils/isohybrid.c has an option to add a suitable MBR partition and GPT to such an 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. Regrettably there seem to be some UEFI implementations which boot from MBR and fail to boot if GPT is present. Therefore some Linux distributions have special ISO images for amd64 which contain only BIOS equipment.

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

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

The properly equipped ISO image can then 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 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

After you convinced yourself 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 do:

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

Images prepared with --partok

ISO images, which were prepared by --partok resp. with MBR isohdppx*.bin, have to be copied 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.

See Also