Difference between revisions of "Isohybrid"

From Syslinux Wiki
Jump to: navigation, search
(Added a missing backslash in xorriso example)
m (Wiki formatting. Minor rewording.)
Line 1: Line 1:
 
ISO 9660 filesystems which are created by the mkisofs command
 
ISO 9660 filesystems which are created by the mkisofs command
in the [[ISOLINUX|article about ISOLINUX]]
+
in the article about [[ISOLINUX]]
 
will boot via BIOS or UEFI firmware only from optical media like CD,
 
will boot via BIOS or UEFI firmware only from optical media like CD,
DVD, or BD. (This includes virtual BIOS and virtual CD-ROM.)
+
DVD, or BD.
  
 
The isohybrid feature enhances such filesystems by a  
 
The isohybrid feature enhances such filesystems by a  
[[Master_Boot_Record|Master Boot Record (MBR)]]
+
[[Master Boot Record]] (MBR)
 
for booting via BIOS from disk storage devices like USB flash drives.
 
for booting via BIOS from disk storage devices like USB flash drives.
  
ISOLINUX provides two programs which can do this in image files
+
ISOLINUX provides two alternative programs to apply this feature
or block devices with ISO 9660 filesystems.
+
on image files or block devices with ISO 9660 filesystems:
  
 
* isohybrid.pl needs a perl interpreter and is supposed to be widely portable.
 
* isohybrid.pl needs a perl interpreter and is supposed to be widely portable.
Line 18: Line 18:
  
 
== BIOS ==
 
== BIOS ==
 +
Both isohybrid programs contain MBR code matching the same version
 +
of the ISOLINUX bootloader file, {{nowrap|"<tt>isolinux.bin</tt>"}}.
 +
So always use the isohybrid program
 +
from the '''same''' Syslinux installation
 +
that provided this bootloader file for the ISO 9660 production.
  
Both isohybrid programs contain MBR code which has to match the version
+
The basic usage is simple.  
of the ISOLINUX file isolinux.bin. So always use the program
+
Create a bootable ISO 9660 image file named "output.iso"  
from the same SYSLINUX installation which provided this file
+
by either mkisofs, genisoimage, or xorriso and then treat it by:
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
+
 
<pre>
 
<pre>
 
isohybrid output.iso
 
isohybrid output.iso
 
</pre>
 
</pre>
  
Both programs take expert options which are listed by
+
Both isohybrid programs can take expert options, listed by:
 
<pre>
 
<pre>
 
isohybrid -?
 
isohybrid -?
 
</pre>
 
</pre>
  
The ISO 9660 production program xorriso can enhance its results
+
Optionally, 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.  
 
installation is provided.  
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.
+
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.
  
 
<pre>
 
<pre>
Line 53: Line 56:
  
 
=== MBR selection ===
 
=== MBR selection ===
 +
Syslinux provides six variations of the MBR code,
 +
contained in its isohybrid programs.
 +
The options
 +
{{nowrap|"<tt>--forcehd0</tt>"}},
 +
{{nowrap|"<tt>--ctrlhd0</tt>"}},
 +
{{nowrap|"<tt>--partok</tt>"}}
 +
may be used to choose one of the non-default flavors.
  
SYSLINUX provides six variations of the MBR code, which are contained
+
When booting a "healthy" BIOS:
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.
+
{| class="wikitable"
 
+
|+ <code>isohybrid MBR selection:</code>
* --forcehd0 chooses isohdpfx_f.bin, which forces booting from BIOS drive 0x80.
+
! Option
 
+
! MBR File
* --ctrlhd0 chooses isohdpfx_c.bin, which forces BIOS drive 0x80 only if the Ctrl key is held during boot.
+
! Comments
 
+
|-
* --partok chooses isohdppx.bin, which is for booting from a device partition by a healthy BIOS.
+
| no options (default)
 
+
| isohdpfx.bin
* --partok --forcehd0 chooses isohdppx_f.bin, for booting from a partition of BIOS disk 0x80.
+
| Boot from base device
 
+
|-
* --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.
+
| --forcehd0
 +
| isohdpfx_f.bin
 +
| Boot from BIOS disk 0x80
 +
|-
 +
| --ctrlhd0
 +
| isohdpfx_c.bin
 +
| If the Ctrl key is held during boot time,<br />&nbsp;&nbsp;then boot from BIOS disk 0x80
 +
|-
 +
| --partok
 +
| isohdppx.bin
 +
| Boot from a partition device<br />&nbsp;&nbsp;(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,<br />&nbsp;&nbsp;then boot from BIOS disk 0x80;<br />Otherwise, boot from a partition device.
 +
|}
  
 
== UEFI ==
 
== UEFI ==
 
The additional isohybrid feature for UEFI adds a partition to the MBR
 
The additional isohybrid feature for UEFI adds a partition to the MBR
partition table which points to the same file in the ISO 9660
+
partition table pointing to the same file in the ISO 9660
 
filesystem as does the El Torito catalog entry for EFI.
 
filesystem as does the El Torito catalog entry for EFI.
 
This file contains a FAT filesystem with boot equipment from
 
This file contains a FAT filesystem with boot equipment from
 
which the UEFI firmware will be able to start the desired
 
which the UEFI firmware will be able to start the desired
 
operating system.
 
operating system.
Further isohybrid for UEFI creates a GUID Partition Table (GPT)
+
Furthermore, isohybrid for UEFI creates a GUID Partition Table (GPT)
with a partition which points to that file.
+
with a partition pointing to that file.
  
 
It can be brought into the ISO 9660 filesystem as second boot
 
It can be brought into the ISO 9660 filesystem as second boot
image with options -eltorito-alt-boot and -e by Fedora's variant
+
image with options {{nowrap|"<tt>-eltorito-alt-boot</tt>"}} and {{nowrap|"<tt>-e</tt>"}} by Fedora's variant
of genisoimage or by xorriso.
+
of genisoimage, or by xorriso:
  
 
<pre>
 
<pre>
Line 89: Line 115:
 
   -o output.iso \
 
   -o output.iso \
 
   -c isolinux/boot.cat \
 
   -c isolinux/boot.cat \
   -b isolinux/isolinux.bin
+
   -b isolinux/isolinux.bin \
 
       -no-emul-boot -boot-load-size 4 -boot-info-table \
 
       -no-emul-boot -boot-load-size 4 -boot-info-table \
 
   -eltorito-alt-boot \
 
   -eltorito-alt-boot \
Line 96: Line 122:
 
   CD_root
 
   CD_root
 
</pre>
 
</pre>
With mkisofs replace
+
With mkisofs, replace the above:
 
<pre>
 
<pre>
 
   -e isolinux/efiboot.img \
 
   -e isolinux/efiboot.img \
 
</pre>
 
</pre>
by
+
by:
 
<pre>
 
<pre>
 
   -eltorito-platform 0xEF -eltorito-boot isolinux/efiboot.img \
 
   -eltorito-platform 0xEF -eltorito-boot isolinux/efiboot.img \
Line 106: Line 132:
  
 
The isohybrid tool compiled from utils/isohybrid.c has an option
 
The isohybrid tool compiled from utils/isohybrid.c has an option
to add a suitable MBR partition and GPT to such an UEFI bootable
+
to add a suitable MBR partition and GPT to such a UEFI bootable
filesystem.
+
filesystem:
 
<pre>
 
<pre>
 
isohybrid --uefi output.iso
 
isohybrid --uefi output.iso
Line 113: Line 139:
 
The ISO 9660 filesystem is then supposed to boot from optical media
 
The ISO 9660 filesystem is then supposed to boot from optical media
 
and from disk storage via BIOS and via UEFI.
 
and from disk storage via BIOS and via UEFI.
Regrettably there seem to be some UEFI implementations which boot
+
Unfortunately, there seem to be some UEFI implementations which boot
 
from MBR and fail to boot if GPT is present. Therefore some Linux
 
from MBR and fail to boot if GPT is present. Therefore some Linux
distributions have special ISO images for amd64 which contain
+
distributions have special ISO images for amd64 containing
 
only BIOS equipment.
 
only BIOS equipment.
  
xorriso can add the GPT equipment by its option -isohybrid-gpt-basdat:
+
xorriso can add the GPT equipment by its  
 +
{{nowrap|"<tt>-isohybrid-gpt-basdat</tt>"}} option:
 
<pre>
 
<pre>
 
xorriso -as mkisofs \
 
xorriso -as mkisofs \
Line 124: Line 151:
 
   -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin \
 
   -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin \
 
   -c isolinux/boot.cat \
 
   -c isolinux/boot.cat \
   -b isolinux/isolinux.bin
+
   -b isolinux/isolinux.bin \
 
       -no-emul-boot -boot-load-size 4 -boot-info-table \
 
       -no-emul-boot -boot-load-size 4 -boot-info-table \
 
   -eltorito-alt-boot \
 
   -eltorito-alt-boot \
Line 136: Line 163:
  
 
== Copying onto USB stick by shell commands ==
 
== 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.
+
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.
+
The advantage of an isohybrid image is that it can also be easily "burned"  
Such storage media then can boot the system in a similar way as the read-only optical media.
+
(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.
 
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
+
Unless option {{nowrap|"<tt>--partok</tt>"}} is used,  
 +
it has to be copied to the base disk
 
device so that it overwrites the partition table.
 
device so that it overwrites the partition table.
 
Partition editors may then be used to make the remaining storage capacity
 
Partition editors may then be used to make the remaining storage capacity
 
available as additional partition for a read-write filesystem.
 
available as additional partition for a read-write filesystem.
  
The following procedure is for ISO images prepared without --partok.
+
The following procedure is for ISO images prepared without  
 +
{{nowrap|"<tt>--partok</tt>"}}.
 
    
 
    
 
=== Verify device address or make a backup ===
 
=== Verify device address or make a backup ===
Line 155: Line 189:
  
 
So first verify that the device file address really leads to the
 
So first verify that the device file address really leads to the
intended device. E.g. by reading a few megabytes and watching it
+
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 :
+
blink).  
 +
If the USB stick is supposed to be Linux device {{nowrap|"<tt>/dev/sdb</tt>":}}
 
<pre>
 
<pre>
 
umount /dev/sdb
 
umount /dev/sdb
Line 162: Line 197:
 
</pre>
 
</pre>
 
or by making a backup of its complete content in a compressed
 
or by making a backup of its complete content in a compressed
disk file:
+
disk file&nbsp;:
 
<pre>
 
<pre>
 
umount /dev/sdb
 
umount /dev/sdb
Line 169: Line 204:
  
 
=== Write to USB stick ===
 
=== Write to USB stick ===
After you convinced yourself that this is the right device file
+
Once you are convinced that this is the right device file
address, copy the ISO image onto the USB stick by
+
address, copy the ISO image onto the USB stick by:
 
<pre>
 
<pre>
 
dd if=output.iso bs=2048 of=/dev/sdb
 
dd if=output.iso bs=2048 of=/dev/sdb
Line 177: Line 212:
 
=== Eventually restore backup ===
 
=== Eventually restore backup ===
 
To later restore the original content of the USB stick, take the
 
To later restore the original content of the USB stick, take the
same care to really use the correct address and do:
+
same care to really use the correct address and then:
 
<pre>
 
<pre>
 
dd if="$HOME"/red_usb_stick.gz | gunzip >/dev/sdb
 
dd if="$HOME"/red_usb_stick.gz | gunzip >/dev/sdb
Line 183: Line 218:
  
 
=== Images prepared with --partok ===
 
=== Images prepared with --partok ===
ISO images, which were prepared by --partok resp. with  
+
ISO images that were prepared by {{nowrap|"<tt>--partok</tt>"}} resp. with  
MBR isohdppx*.bin, have to be copied to a partition device.
+
MBR {{nowrap|"<tt>isohdppx*.bin</tt>"}} have to be dd' to a <u>partition</u> device.
E.g. /dev/sdb1 rather than /dev/sdb.
+
E.g. {{nowrap|/dev/sdb1}} rather than {{nowrap|/dev/sdb}}.
 
Such an ISO partition may then be booted by chainloading or
 
Such an ISO partition may then be booted by chainloading or
 
by a suitable MBR at the start of the base disk device.
 
by a suitable MBR at the start of the base disk device.
Line 191: Line 226:
 
== See Also ==
 
== See Also ==
 
* [http://cdrtools.sourceforge.net/private/man/cdrecord/mkisofs.8.html man 8 mkisofs] Manual of mkisofs.
 
* [http://cdrtools.sourceforge.net/private/man/cdrecord/mkisofs.8.html man 8 mkisofs] Manual of mkisofs.
 +
<!-- * [http://cdrtools.sourceforge.net/private/man/mkisofs-2.0.html Manpage of mkisofs-2.0] Old version; just for reference.  -->
 +
<!-- * [http://cdrtools.sourceforge.net/private/man/mkhybrid-1.12.1.html Manpage of mkhybrid-1.12.1] Old version; just for reference.  -->
 
* [http://linux.die.net/man/1/genisoimage man 1 genisoimage] Manual of genisoimage.
 
* [http://linux.die.net/man/1/genisoimage man 1 genisoimage] Manual of genisoimage.
 
* [http://www.gnu.org/software/xorriso/man_1_xorrisofs.html man 1 xorrisofs] Manual of xorriso's emulation of mkisofs.
 
* [http://www.gnu.org/software/xorriso/man_1_xorrisofs.html man 1 xorrisofs] Manual of xorriso's emulation of mkisofs.

Revision as of 08:35, 4 October 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.

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.

Meanwhile there is an additional isohybrid feature for UEFI.

BIOS

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

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 -?

Optionally, 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, 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

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, replace the above:

   -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 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 which 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 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" resp. with MBR "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.

See Also