0

I'm working on a script to abstract the creation of 24.04 Ubuntu remixes, similar to Cubic. The commands I'm using are summarized below, and the resulting ISO is barely bootable in VirtualBox [everything I've produced has not made it past the error "Unable to Find a Medium Containing a Live File System"]. To those who create custom Ubuntu ISOs beyond > 22.04 in the post-isolinux era, any suggestions? These commands should be relatively straightforward (given, I haven't even made an attempt to modify minimal.squashfs yet):

cd ~/Desktop

sudo mkdir /mnt/iso

sudo mount -o loop ubuntu-24.04-desktop-amd64.iso /mnt/iso

mkdir ~/custom-ubuntu

cp -r /mnt/iso/* ~/custom-ubuntu/

sudo umount /mnt/iso

cd ~/custom-ubuntu

chmod +w -R .

cd ~/custom-ubuntu/casper

mkdir extract

sudo unsquashfs -d extract minimal.squashfs

sudo chroot extract glib-compile-schemas /usr/share/glib-2.0/schemas/

sudo rm minimal.squashfs

sudo mksquashfs extract minimal.squashfs -comp xz -e boot

sudo rm -rf extract

sudo sed -i "s/^[0-9]* .*/$(sudo du -sx --block-size=1 extract | cut -f1) minimal.squashfs/" filesystem.size

cd ~/Desktop

orig=ubuntu-24.04-desktop-amd64.iso

mbr=ubuntu-mbr.img

efi=ubuntu-efi.img

dd if="$orig" bs=1 count=446 of="$mbr"

skip=$(fdisk -l "$orig" | fgrep '.iso2 ' | awk '{print $2}')

size=$(fdisk -l "$orig" | fgrep '.iso2 ' | awk '{print $4}')

dd if="$orig" bs=512 skip="$skip" count="$size" of="$efi"

new=~/Desktop/ubuntu-custom.iso

disk_title="Ubuntu Custom"

sudo xorriso -as mkisofs
-r -V "$disk_title" -J -joliet-long -l
-iso-level 3
-partition_offset 16
--grub2-mbr "$mbr"
--mbr-force-bootable
-append_partition 2 0xEF "$efi"
-appended_part_as_gpt
-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:all::'
-no-emul-boot
-o "$new"
~/custom-ubuntu

BryFitz91
  • 1
  • 1

1 Answers1

0

I had a similar task and was on the same path like you, extracting the boot parts via fdsik. Then I found this blog: Daniel Persson - Looki Looki No Hands, Automatic install of Ubuntu server (Be sure to watch the video for the explanation)

TLDR; you can do extract the via xorriso INCLUDING the bootparts:

mkdir source-files
xorriso -osirrox on -indev ubuntu-24.04.1-live-server-amd64.iso -- 
extract_boot_images source-files/bootpart -extract / source-files

after modifying the parts i need (grub etc) i put everything together with the following command which i modified from this post Ubuntu 22.04 build ISO (Both: MBR and EFI ):

xorriso -as mkisofs -r \
    -V "u2404-modif" \
    -o ../ubuntu-modif.iso \
    --grub2-mbr bootpart/mbr_code_grub2.img \
    -partition_offset 16 \
    --mbr-force-bootable \
    -append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b bootpart/gpt_part2_efi.img \
    -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 \
    .

(Mind the dot for the current directory!)

PS: My goal for this was have UEFI Boot (BIOS is a bonus) PPS: I use the Server Image, but i hope it works for desktop to or at least points you in the right direction