Re: Hybrid ISO with GPT
Hi,
Joe Daily wrote:
> Is it possible to get live-build to output an image with a GPT table instead
> of MBR? If so any recommendations?
Without changing the debian-live production software, i see two approaches:
- Manipulate partition table after normal ISO production.
- Repack normal ISO by an alternative xorriso run.
--------------------------------------------------------------------------
Manipulate partition table after normal ISO production:
debian-live-9.5.0-i386-xfce.iso already has a GPT. It is just not
announced by a "protective" MBR partition table and it is ill in respect
to overlapping of partitions and the type GUID of the EFI partition.
If you use fdisk to delete MBR partition 2 and to change partition 1
so that it starts at block 0 and has type 0xEE, then the GPT should become
recognizable.
$ cp debian-live-9.5.0-i386-xfce.iso test.iso
$ /sbin/fdisk test.iso
...
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): ee
Changed type of partition 'Empty' to 'GPT'.
Command (m for help): x
Expert command (m for help): b
elected partition 1
New beginning of data (1-3876543): 1
Expert command (m for help): r
Command (m for help): p
...
Device Boot Start End Sectors Size Id Type
test.iso1 * 1 3876543 3876543 1.9G ee GPT
Command (m for help): w
The partition table has been altered.
Next problem is the type of GPT partition 2. The isohybrid layout marks it
as "Microsoft Basic Data".
Further problem is that partition 1 encloses partition 2. Number 1 is useless
anyways, because it does not begin at the start of the ISO filesystem.
You can fix this by gdisk:
$ /sbin/gdisk test.iso
...
Command (? for help): d
Partition number (1-2): 1
Command (? for help): t
Using 2
Current type is 'Microsoft basic data'
Hex code or GUID (L to show codes, Enter = 8300): EF00
Changed type of partition to 'EFI System'
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to test.iso.
The ISO will only be mountable via the base device, not by any partition.
You may add two dummy partitions before and after the remaining EFI
partition in order to protect the data range of the ISO filesystem from
being claimed by future partitions.
-----------------------------------------------------------------------
Repack normal ISO by an alternative xorriso run:
A wider approach would be to repack the ISO so that its partition layout
resembles the ARM64 netinst ISO, which is EFI only.
$ sudo mount debian-live-9.5.0-i386-xfce.iso /mnt/iso
$ cp /mnt/iso/boot/grub/efi.img ./efi.img
$ xorriso -as mkisofs \
-r -V 'd-live 9.5.0 xf i386' \
-o test.iso \
-J -joliet-long -cache-inodes \
-append_partition 2 0xef ./efi.img \
-appended_part_as_gpt \
-e --interval:appended_partition_2:all:: \
-no-emul-boot \
-partition_offset 16 \
-no-pad \
/mnt/iso
$ rm ./efi.img
This will yield the following partition layout
$ /sbin/fdisk -l test.iso
...
Disklabel type: gpt
Disk identifier: D73BA8FD-5DF6-43C8-8DDC-358551468C2C
Device Start End Sectors Size Type
test.iso1 64 3878399 3878336 1.9G Microsoft basic data
test.iso2 3878400 3879039 640 320K EFI System
Debians ARM64 ISOs are partitioned by MBR, not GPT.
Option -appended_part_as_gpt caused the production of GPT instead of an
MBR partition table (which is normally better suited for an image file).
xorrisofs option
-e --interval:appended_partition_2:all::
marked the appended partition in the EL Torito boot catalog. This is of
interest only if you boot from CD, DVD or BD medium. You may omit it
if you only want to boot from HDD-like devices.
Due to option -partition_offset 16, there is a mountable ISO 9660 superblock
at the start of the first partition (64 * 512 = 32768):
$ sudo mount -o offset=32768 /dvdbuffer/test.iso /mnt/iso2
mount: /dev/loop1 is write-protected, mounting read-only
The EFI partition is of course mountable too:
$ sudo mount -o offset=1985740800 /dvdbuffer/test.iso /mnt/fat
If you omit option -no-pad, then a third partition emerges which covers
the appended padding. It is not mountable and may be deleted or re-used
for data storage.
(Setting a better partition type than "Microsoft basic data" is a yet
unreleased feature of xorriso-1.5.1 :
-iso_mbr_part_type 0FC63DAF-8483-4772-8E79-3D69D8477DE4
Version 1.5.0 can only choose the ISO partition type in MBR partition table)
-iso_mbr_part_type 0x83
)
(Above layout can be combined with ISOLINUX isohybrid for BIOS or with
a GRUB2 MBR for ISO booting via BIOS.)
Have a nice day :)
Thomas
Reply to: