2010-09-23 13:56:22 +00:00
|
|
|
|
|
|
|
The partition offset feature of libisofs can produce ISO 9660 images which bear
|
|
|
|
a quite conventional partition table if copied onto a USB stick. The first
|
|
|
|
partition marks the size of the ISO image but starts at a non-zero address.
|
|
|
|
Thus it marks a small part of the device as unclaimed by partitions and
|
|
|
|
available for storing boot loader code.
|
|
|
|
|
|
|
|
Nevertheless the USB stick is mountable via its overall device file as well as
|
2017-09-06 12:42:21 +00:00
|
|
|
via the partition device file. E.g. on GNU/Linux: `/dev/sdb` and `/dev/sdb1`.
|
2010-09-23 13:56:22 +00:00
|
|
|
This is achieved by two distinct sets of meta-data which refer to the same
|
|
|
|
file content.
|
|
|
|
|
2011-06-17 14:39:24 +00:00
|
|
|
The dual-mount feature supports Rock Ridge and Joliet too.
|
2010-09-23 13:56:22 +00:00
|
|
|
It is capable of multi-session.
|
|
|
|
|
|
|
|
Currently only offset 32 kB seems to make sense. Smaller offsets are prohibited
|
|
|
|
by fundamental assumptions of libisofs and libisoburn. Larger offsets would
|
|
|
|
extend the unclaimed area into vital blocks of the ISO image.
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------
|
|
|
|
|
2011-04-19 09:10:02 +00:00
|
|
|
According to a
|
2017-09-06 12:42:21 +00:00
|
|
|
[thread of march 2011](http://www.syslinux.org/archives/2011-March/016527.html)
|
2011-04-19 09:10:02 +00:00
|
|
|
on Syslinux mailing list this enabled booting of a Kontron CG2100 server
|
|
|
|
from USB stick, which otherwise failed.
|
|
|
|
|
|
|
|
Regrettably the feature seems to prevent mounting of ISO 9660 images on
|
|
|
|
Apple "Snow Leopard" systems.
|
|
|
|
At least this is the outcome of a
|
2017-09-06 12:42:21 +00:00
|
|
|
[debian-cd thread of april 2011](http://lists.debian.org/debian-cd/2011/04/msg00029.html).
|
2011-04-19 09:10:02 +00:00
|
|
|
|
2010-12-30 22:00:24 +00:00
|
|
|
--------------------------------------------------------------------------
|
|
|
|
|
2010-09-23 13:56:22 +00:00
|
|
|
Example:
|
|
|
|
|
|
|
|
Testing mountability and ISOLINUX bootability from USB stick and CD.
|
|
|
|
|
|
|
|
Overview:
|
|
|
|
|
|
|
|
The test image was derived from one year old RIPLinux-9.3-non-X.iso which
|
|
|
|
has an isohybrid MBR. Syslinux version seems to be 3.82. That MBR and the file
|
|
|
|
tree from the mounted RIPLinux image was used to build a new ISO image
|
2017-09-06 12:42:21 +00:00
|
|
|
with 16 \* 2kB partition offset. Isohybrid MBR patching was done by xorriso.
|
2010-09-23 13:56:22 +00:00
|
|
|
|
|
|
|
Details:
|
|
|
|
|
|
|
|
The first 32 kB of an ISO 9660 image are called System Area and may host any
|
2015-07-31 17:12:51 +00:00
|
|
|
byte pattern. The first 512 bytes of RIPLinux-9.3-non-X.iso contain the
|
|
|
|
isohybrid capable MBR, which will be re-used in this example.
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2015-07-31 17:12:51 +00:00
|
|
|
dd if=RIPLinux-9.3-non-X.iso bs=512 count=1 of=RIPLinux-9.3-non-X.mbr
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2015-07-31 17:12:51 +00:00
|
|
|
Normally the isohybrid MBR is provided by the Syslinux
|
2017-09-06 12:42:21 +00:00
|
|
|
installation under the name `isohdp[fp]x*.bin` .
|
|
|
|
E.g. `/usr/lib/syslinux/isohdpfx.bin`
|
2011-03-09 11:01:48 +00:00
|
|
|
|
2010-09-23 13:56:22 +00:00
|
|
|
The files of the image are made accessible for reading
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
mount -o loop RIPLinux-9.3-non-X.iso /mnt
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
|
|
|
|
A new ISO image gets composed. The first three lines of arguments are taken
|
|
|
|
from the prescriptions of ISOLINUX wiki and adapted to the names used in
|
|
|
|
RIPLinux-9.3-non-X.iso.
|
2017-09-06 12:42:21 +00:00
|
|
|
Option `-isohybrid-mbr` imports the copied MBR and patches it
|
2010-09-23 13:56:22 +00:00
|
|
|
according to rules published by hpa on Syslinux mailing list.
|
2017-09-06 12:42:21 +00:00
|
|
|
Option `-partition_offset 16` causes the first partition to start at 2 kB block
|
2010-09-23 13:56:22 +00:00
|
|
|
number 16. It also prepares the image to be mountable by this partition, too.
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
xorriso -as mkisofs \
|
|
|
|
-o new_image.iso \
|
|
|
|
-b boot/isolinux/isolinux.bin -c boot/boot.cat \
|
|
|
|
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
2015-07-31 17:12:51 +00:00
|
|
|
-isohybrid-mbr RIPLinux-9.3-non-X.mbr \
|
2010-09-23 13:56:22 +00:00
|
|
|
-partition_offset 16 \
|
|
|
|
/mnt
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
The image was copied onto a USB stick
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
dd if=new_image.iso of=/dev/sdc
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
and plugged into a Debian system.
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
fdisk -lu /dev/sdb
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
yields
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
Device Boot Start End Blocks Id System
|
2011-03-09 11:01:48 +00:00
|
|
|
/dev/sdb1 * 64 120831 60384 17 Hidden HPFS/NTFS
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
|
2017-09-06 12:42:21 +00:00
|
|
|
I can mount `/dev/sdb` and `/dev/sdb1` alike:
|
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
mount /dev/sdb1 /mnt1
|
|
|
|
mount -o loop /dev/sdb /mnt
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
|
|
|
`-o loop` avoids failure with "mount: /dev/sdb already mounted or /mnt busy".
|
2010-09-23 13:56:22 +00:00
|
|
|
A comparison by
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
diff -r /mnt /mnt1
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
reports no difference.
|
|
|
|
Human readable files look ok.
|
|
|
|
Test-reading all content by
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
tar cf - /mnt | wc
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
yields a reasonable byte count of 60743680 and no errors.
|
|
|
|
|
|
|
|
The machine boots RIPLinux from this USB stick with no visible problems.
|
2017-09-06 12:42:21 +00:00
|
|
|
It can then mount `/dev/sdb` as well as `/dev/sdb1`.
|
2010-09-23 13:56:22 +00:00
|
|
|
The ISO image boots from CD too.
|
|
|
|
|
|
|
|
Mounting the partition can be simulated with an image file on hard disk by
|
|
|
|
cutting off the first partition_offset blocks of 2 KB:
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
dd if=new_image.iso of=partition_image.iso bs=2048 skip=16
|
|
|
|
mount -o loop partition_image.iso /mnt1
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------
|
|
|
|
|
2010-09-29 08:55:30 +00:00
|
|
|
Another test was made with GRUB 2 by downloading
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-29 08:55:30 +00:00
|
|
|
bzr branch http://bzr.savannah.gnu.org/r/grub/trunk/grub
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-29 08:55:30 +00:00
|
|
|
|
|
|
|
Before building GRUB 2, the file
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-29 08:55:30 +00:00
|
|
|
util/grub-mkrescue.in
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-29 08:55:30 +00:00
|
|
|
was edited to replace in the options of the xorriso command:
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-29 08:55:30 +00:00
|
|
|
--protective-msdos-label
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-29 08:55:30 +00:00
|
|
|
by
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2011-04-07 18:04:16 +00:00
|
|
|
-partition_offset 16 -no-pad
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-29 08:55:30 +00:00
|
|
|
Then GRUB 2 was built and installed.
|
|
|
|
|
|
|
|
The resulting image from
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-29 08:55:30 +00:00
|
|
|
./grub-mkrescue -o image.iso
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-29 08:55:30 +00:00
|
|
|
was put onto USB stick. It passed the same tests on Debian
|
|
|
|
as above RIPLinux example. It boots to a GRUB prompt.
|
|
|
|
|
2017-09-06 12:42:21 +00:00
|
|
|
Due to option `-no-pad` the image is about 250 kB smaller than
|
|
|
|
the image produced by original `grub-mkrescue`. Else it would have grown by
|
2011-04-07 18:04:16 +00:00
|
|
|
about 50 kB.
|
|
|
|
|
|
|
|
Unpadded ISO images are safe except for burning on CD in TAO mode.
|
|
|
|
In this case problems may occur with reading the last few data blocks.
|
|
|
|
So when burning onto CD make sure to require SAO mode and/or to
|
2011-04-19 09:10:02 +00:00
|
|
|
require padding by 300 kB.
|
2011-04-07 18:04:16 +00:00
|
|
|
Burning on DVD or BD needs no such caution. Neither does copying
|
|
|
|
on USB stick or hard disk.
|
|
|
|
|
2017-09-06 12:42:21 +00:00
|
|
|
Program `fdisk` will complain about "different physical/logical" addresses.
|
2011-04-07 18:04:16 +00:00
|
|
|
This can be silenced by adding option
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2011-04-07 18:04:16 +00:00
|
|
|
-partition_cyl_align on
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2011-04-19 09:10:02 +00:00
|
|
|
at the cost of image padding up to the next full MB.
|
|
|
|
E.g. by 402 kB to 2 MB.
|
2010-09-29 08:55:30 +00:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------
|
|
|
|
|
2010-09-23 13:56:22 +00:00
|
|
|
Open questions:
|
|
|
|
|
|
|
|
- Shall the partition of an isohybrid image be marked bootable ?
|
2011-06-17 14:39:24 +00:00
|
|
|
Currently xorriso keeps the 0x80 mark of an imported MBR
|
2015-07-31 17:12:51 +00:00
|
|
|
and the 0x80 mark which xorriso sets by its own MBR
|
2010-09-23 13:56:22 +00:00
|
|
|
preparations.
|
|
|
|
- If not to be marked bootable:
|
|
|
|
What equipment would the partition need to justify having the mark ?
|
|
|
|
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Application:
|
|
|
|
|
2011-04-07 18:04:16 +00:00
|
|
|
The partition offset feature can be controlled by libisofs API calls
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
int iso_write_opts_set_part_offset(IsoWriteOpts *opts,
|
|
|
|
uint32_t block_offset_2k,
|
|
|
|
int secs_512_per_head,
|
|
|
|
int heads_per_cyl);
|
2011-04-07 18:04:16 +00:00
|
|
|
|
|
|
|
int iso_write_opts_set_system_area(IsoWriteOpts *opts, char data[32768],
|
|
|
|
int options, int flag);
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2015-07-31 17:12:51 +00:00
|
|
|
or by libisoburn calls
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
int isoburn_igopt_set_part_offset(struct isoburn_imgen_opts *opts,
|
|
|
|
uint32_t block_offset_2k,
|
|
|
|
int secs_512_per_head, int heads_per_cyl);
|
|
|
|
|
|
|
|
int isoburn_igopt_get_part_offset(struct isoburn_imgen_opts *opts,
|
|
|
|
uint32_t *block_offset_2k,
|
|
|
|
int *secs_512_per_head, int *heads_per_cyl);
|
2011-04-07 18:04:16 +00:00
|
|
|
|
|
|
|
int isoburn_igopt_set_system_area(struct isoburn_imgen_opts *o,
|
|
|
|
char data[32768], int options);
|
|
|
|
|
|
|
|
int isoburn_igopt_get_system_area(struct isoburn_imgen_opts *o,
|
|
|
|
char data[32768], int *options);
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2015-07-31 17:12:51 +00:00
|
|
|
or by xorriso options
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
-boot_image any partition_offset=(2kb_block_adr)
|
|
|
|
-boot_image any partition_sec_hd=(number)
|
|
|
|
-boot_image any partition_hd_cyl=(number)
|
2011-04-07 18:04:16 +00:00
|
|
|
-boot_image any partition_cyl_align(on|auto|off)
|
|
|
|
|
|
|
|
-as mkisofs ... -partition_offset (2kb_block_adr) \
|
|
|
|
-partition_hd_cyl (number) \
|
|
|
|
-partition_sec_hd (number) \
|
|
|
|
-partition_cyl_align (on|auto|off) ...
|
2017-09-06 12:42:21 +00:00
|
|
|
```
|
2010-09-23 13:56:22 +00:00
|
|
|
|
|
|
|
As stated above, an offset larger than 16 would expose vital parts of the
|
|
|
|
ISO image as unclaimed space. Values smaller than 16 are not accepted.
|
|
|
|
So use either an offset of 16 blocks or keep the feature disabled by
|
|
|
|
offset 0.
|
|
|
|
|