2

This is a follow up question to Ubuntu 22.04 build ISO (Both: MBR and EFI ) . Unfortunately I don't have the reputation score to make comments on the original.

I, too, create modified iso images for my install purposes except in my case I use the live server iso. I adapted the very useful answer by Thomas Schmitt at the URL above. After adjusting to the use of a the 22.04 server iso and burning my custom iso I get a working boot USB stick but with a bad backup GPT table. Here is an excerpt of dmesg from when it mounts on my laptop:

[3991990.397058] GPT:Primary header thinks Alt. header is not at the end of the disk.
[3991990.397063] GPT:2872323 != 30310399
[3991990.397066] GPT:Alternate GPT header not at the end of the disk.
[3991990.397067] GPT:2872323 != 30310399

When booting up from that USB stick there are similar messages. In that case the kernel complains and adjusts itself with messages like "The backup GPT table is corrupt, but the primary appears OK, so that will be used." However I know there must be a way to adjust xorriso to fix the secondary table that I do not know.

Of course the partition layout is different than with the desktop iso version. To explain the numbers in the code segment below, here is that layout.

#/sbin/fdisk -l ubuntu-22.04-live-server-amd64.iso
Disk ubuntu-22.04-live-server-amd64.iso: 1.37 GiB, 1466714112 bytes, 2864676 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: C84E0225-4BE7-447A-9FA1-EBF040BDC01F

Device Start End Sectors Size Type ubuntu-22.04-live-server-amd64.iso1 64 2855515 2855452 1.4G Microsoft basic data ubuntu-22.04-live-server-amd64.iso2 2855516 2864011 8496 4.2M EFI System ubuntu-22.04-live-server-amd64.iso3 2864012 2864611 600 300K Microsoft basic data

Based on what Thomas Schmitt wrote in his answer for the desktop iso, I wrote this bash script:

#!/bin/bash

#output name of image IMAGE=ubuntu22_04_custom.iso

OPWD=/home/[something]/ubuntu_22_04_isomaker/

cd $OPWD

#this is where the files for the custom iso are located BUILD=$OPWD/iso_raw/

#this is a copy of the original iso as downloaded BASE_IMAGE=$OPWD/baseiso/ubuntu-22.04-live-server-amd64.iso

#extract MBR / EFI MBR_IMAGE=$OPWD/partitions/ubuntu_isohybrid_mbr.img EFI_IMAGE=$OPWD/partitions/efi.img BASE_IMAGE=$OPWD/baseiso/ubuntu-22.04-live-server-amd64.iso

dd if="$BASE_IMAGE" bs=1 count=432 of="$MBR_IMAGE"

dd if="$BASE_IMAGE" bs=512 skip=2855516 count=8496 of="$EFI_IMAGE"

make the md5sum for the modified iso

cd $BUILD

rm -f md5sum.txt find . -type f -not -name md5sum.txt -print0 | xargs -0 md5sum | tee md5sum.txt

cd $OPWD

Finally pack up an ISO the new way

/usr/local/bin/xorriso -as mkisofs -r
-V 'Ubuntu 22.04'
-o "$IMAGE"
--grub2-mbr "$MBR_IMAGE"
-partition_offset 16
--mbr-force-bootable
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b $EFI_IMAGE
-appended_part_as_gpt
-iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7
-c '/boot.catalog'
-b '/boot/grub/i386-pc/eltorito.img'
-no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info
-eltorito-alt-boot
-e '--interval:appended_partition_2:::'
-no-emul-boot
"$BUILD"

exit 0

For the record, the version of xorriso being used is 1.5.4.pl02 (built yesterday).

So how do I make xorriso properly write the secondary GPT table?

Dave LeFevre
  • 63
  • 1
  • 5

1 Answers1

3

The complaints are inavoidable unless your USB stick offers exactly the same size capacity as the size of the image needs. GPT specifications prescribe a main partition table at the start of the storage device and a backup table at its end. In the ISO image this table is where it belongs. But after copying to the USB stick, there are still unused blocks after the backup table.

The complaint is harmless until you want to add partitions to your USB stick. Partition editors will issue a similar complaint and should offer to repair the situation. I find in my mail box a success report of an experiment with sfdisk 2.33.1 to add a partition named "DATA" which claims all unused space of the USB stick at /dev/sdc:


echo 'name=DATA' | sudo sfdisk -a /dev/sdc

This salvaged the backup GPT situation, too.

An MBR partition table instead of GPT would avoid the problem. But there are EFI implementations known which do not accept an USB stick for booting if it does not have a smell of GPT. The old Ubuntu ISO layout was a jackalope with an invalid GPT strapped to its back. Modern partition editors usually perceive it as the bad result of a major disk mishap. The situation with a misplaced backup GPT is less outraging to them.

If you have more questions about xorriso, please send mail to:

bug-xorriso@gnu.org

I cannot guarantee that i will notice your posts at askubuntu.com or that it will allow me answer.

Have a nice day :)

Thomas