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?