mkisofs is a utility that creates an ISO 9660 image from files on disk.
From man page, "mkisofs is effectively a pre-mastering program to generate the iso9660 filesystem - it takes a snapshot of a given directory tree, and generates a binary image which will correspond to an iso9660 filesystem when written to a block device."
Developers of operating systems will mainly be interested in creating ISO filesystems for bootable CD, DVD, or BD via El-Torito. Nevertheless, ISO filesystems may also be booted from hard disk or USB stick.
Mkisofs, its Clone, and its Emulator
The program mkisofs is part of the cdrtools project by Joerg Schilling.
Some quarrels with the GNU/Linux community caused a fork of cdrtools, named cdrkit. The corresponding fork of mkisofs is named genisoimage. You will find it installed as "mkisofs" on many popular GNU/Linux distributions.
An independent alternative to mkisofs is xorriso, which has an emulation mode that understands the options which are used with mkisofs for producing a bootable ISO 9660 image. Most distributions have it either as package "xorriso" or as part of "libisoburn". GRUB2 script grub-mkrescue depends on xorriso-0.5.6 or newer.
prog="xorriso -as mkisofs"
Warning: Defaults of xorriso -as mkisofs emulation might deviate from those of mkisofs. E.g. not specifying -boot-load-size assumes a default of four sectors instead of the entire boot file.
Options and input files
A mkisofs run needs one or more input directories or files and a name for the emerging filesystem image file. There are options for standards compliance, for filesystem attributes, and -most important here- for setting up boot entry points.
-o DISKPATH sets the result file name. E.g. "bootable.iso".
-R enables normal Unix filenames and attributes by Rock Ridge extension. -r does the same but also changes access permissions to make all files readable by everybody.
-J enables MS-Windows UCS-2 names via Joliet extension.
-iso-level NUMBER sets the ISO 9660 Level of Interchange. Level 1 allows only 8.3 filenames. Level 2 allows up to 30 characters in filenames. Level 3 allows data files larger than 4 GiB - 1.
-U violates ISO 9660 specs by allowing long case-sensitive filenames outside of said extensions. If you know that the reader can stand it, then this is a cheap way to get decent file names. But expect standard readers to become confused.
-V TEXT sets the ISO 9660 Volume ID. It can be up to 32 characters long and is often used by automounters as name of the mount directory for the filesystem.
-hide ISOPATH and -hide-joliet ISOPATH may be used to exclude a data file from the directory trees while still having its content in data blocks of the filesystem.
-c ISOPATH sets the filename for the El Torito Boot Catalog. The file is created automatically if boot images are announced. If option -c is missing, then the file will not show up in the directory trees of the ISO filesystem.
-b ISOPATH announces a data file as El Torito boot image for PC-BIOS.
-e ISOPATH announces a data file as El Torito boot image for EFI. This is not an option of original mkisofs, but is understood by some variants of genisoimage and by xorriso -as mkisofs.
-no-emul-boot and -hard-disk-boot choose emulation modes other than the default of floppy emulation. Especially -no-emul-boot is needed for boot images of ISOLINUX and GRUB2.
-boot-load-size NUMBER sets how many blocks of the boot image are to be loaded by the BIOS. A usual number with -no-emul-boot is 4.
-boot-info-table causes a Boot Info Table to be written into the boot image. Needed for boot images of ISOLINUX and GRUB2.
-eltorito-alt-boot ends the range of -b or -e. All further El Torito boot options will apply to the next boot image given by -b or -e.
-G DISKPATH copies the content of a data file into the System Area of the ISO filesystem. This is used to bring MBR or other boot blocks into the filesystem to enable booting from hard-disk-like devices or booting on exotic hardware.
-isohybrid-mbr DISKPATH copies a SYSLINUX/ISOLINUX MBR template into the System Area and makes it execute the El Torito boot image for BIOS. This is a speciality of xorriso -as mkisofs.
-graft-points enables the interpretation of pathspecs which give a target path in the ISO filesystem together with the path of an input directory or file.
A program argument, which is not recognized as option (e.g. because it does not begin by a dash "-") and is not parameter of an option, is taken as path to an input directory or file. If it is a directory, then its content gets merged with the content of the root directory of the emerging ISO filesystem. If it is a file of other type, then it gets copied into the root directory.
If enabled, then pathspecs get recognized by an equal sign which separates target path from source path. E.g.
into the ISO filesystem as
You want to create a bootable iso image?
First you need to build a bootable floppy image which holds f. ex. grub with your menu.lst and your kernel (and additional required modules).
Then, you put this boot floppy image in a temporary directory, say as /tmp/deploy/boot.img.
After that, you copy all your additional files (applications, images, texts, directories too) into the given directory (f. ex. /tmp/deploy).
Finally, you are ready to produce the ISO filesystem image as /tmp/youriso.iso:
$prog -U -b boot.img -hide boot.img \ -V "Your Name..." -iso-level 3 -o /tmp/youriso.iso /tmp/deploy
Note that the ISOPATH for option -b is relative to the root directory of the ISO filesystem. By providing the floppy image as /tmp/deploy/boot.img you managed to let it appear in the ISO filesystem as /boot.img.
For more examples see El-Torito.
Windows version of mkisofs(through cdrtools) can be downloaded from ftp://ftp.berlios.de/pub/cdrecord/alpha/win32. The following command(inside cygwin) can be used to create bootable iso image without using floopy image.
mkdir -p $ISO_DIR/boot/grub cp $GRUB_BIN/stage2_eltorito $ISO_DIR/boot/grub cp menu.lst $ISO_DIR/boot/grub cp your_kernel $ISO_DIR mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o bootcd.iso $ISO_DIR
- ISO 9660 - technical properties of ISO 9660 filesystems
- El-Torito - structure of bootable ISO 9660 filesystems with mkisofs examples
- Bootable El-Torito CD with GRUB Legacy - tutorial on how to create a "no emulation" bootable CD
- Bootable CD - tutorial on using floppy disk emulation