Bootable ISO Images

Not ready for prime time ...

To make a bootable CD

-> mkdir -p livecd livecd/grub
-> cp /usr/share/grub/i386-redhat/stage2_eltorito livecd/grub
-> genisoimage -R -no-emul-boot -boot-load-size 4 -boot-info-table -b grub/stage2_eltorito \
   -V multilive -o livecd.iso livecd

El Torito CD

-> dd if=win_xp.iso skip=$((16*2048+1)) bs=1 count=5 2> /dev/null; echo
CD001

Alternatively:

 -> hexdump -C -s$((16*2048)) -n 15 win_xp.iso 
00008000  01 43 44 30 30 31 01 00  20 20 20 20 20 20 20     |.CD001..       |
0000800f
dd if=/dev/sr0 of=win_xp.img bs=2048 count=1 skip=$((0x151)

The Primary Volume Descriptor begins at offset 16h and spans a single sector:

->  hexdump -C -s$((16*2048)) -n2048 win_xp.iso
00008000  01 43 44 30 30 31 01 00  20 20 20 20 20 20 20 20  |.CD001..        |
00008010  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00008020  20 20 20 20 20 20 20 20  58 50 5f 48 4f 4d 45 5f  |        XP_HOME_|
00008030  53 50 33 20 20 20 20 20  20 20 20 20 20 20 20 20  |SP3             |
...

Alternatively:

-> dd bs=2048 count=1 skip=16 if=win_xp.iso 2> /dev/null | strings | tr -s " "
CD001
 XP_HOME_SP3 
XP_HOME_SP3 MICROSOFT CORPORATION ...

The Boot Record Volume Descriptor begins at offset 17h and spans 2048 bytes.

-> hexdump -C -s$((17*2048)) -n32 win_xp.iso 
00008800  00 43 44 30 30 31 01 45  4c 20 54 4f 52 49 54 4f  |.CD001.EL TORITO|
00008810  20 53 50 45 43 49 46 49  43 41 54 49 4f 4e 00 00  | SPECIFICATION..|
00008820

Of chief interest, the double-word spanning offsets 47h-4Ah gives the absolute pointer to the Boot Catalog:

-> hexdump -C -s$((17*2048+0x47)) -n4 win_xp.iso 
00008847  13 00 00 00                                       |....|
0000884b

The bytes are in little-endian order. This Boot Catalog, in particular, starts at offset 13h.

The Validation entry is the first entry in the Boot Catalog and spans 32 bytes. A correct Validation Entry implicitly establishes the presence of a valid Boot Catalog and also identifies the CD's publisher. Here, it begins at offset 13h:

-> hexdump -C -s$((0x13*2048)) -n32 win_xp.iso 
00009800  01 00 00 00 4d 69 63 72  6f 73 6f 66 74 20 43 6f  |....Microsoft Co|
00009810  72 70 6f 72 61 74 69 6f  6e 00 00 00 4c 49 55 aa  |rporation...LIU.|
00009820

Initial Default Entry:

-> hexdump -C -s$((0x13*2048+32)) -n32 win_xp.iso 
00009820  88 00 00 00 00 00 10 00  51 01 00 00 00 00 00 00  |........Q.......|
00009830  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00009840

Here, the first byte (88h) indicates that CD is bootable, and the second byte (0h) specifies no-emulation mode. Bytes 6-7 together specify the number of sectors to be stored at Load Segment during the initial boot procedure; here 10h. The four bytes at offsets 8h-Bh give the starting offset of the virtual disk; here 151h.

Section Header Entry:

-> hexdump -C -s$((0x13*2048+48)) -n32 win_xp.iso 
00009830  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00009850

Section Entry:

-> hexdump -C -s$((0x13*2048+64)) -n32 win_xp.iso 
00009830  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00009850