How to Make Ubuntu Autoinstall ISO with Cloud-init in Ubuntu 21.10 - Ask Ubuntu

PHOTO EMBED

Tue Jul 26 2022 17:16:53 GMT+0000 (Coordinated Universal Time)

Saved by @gistbucket #cloud-init

TL;DR:

Use xorriso -indev ubuntu.iso -report_el_torito as_mkisofs to find out the options you need to rebuild the ISO after patching it.

Full steps:

This assumes you have a "ubuntu.iso" and will create a new "ubuntu-autoinstall.iso".

Unpack the ISO with: mkdir new && bsdtar -C new -xf ubuntu.iso

(install libarchive-tools to get bsdtar)

Patch new/boot/grub/grub.cfg as follows:

Modify set timeout=30 to set timeout=1

Add a new menuentry on top of all others as follows:

menuentry "autoinstall" {
   set gfxpayload=keep
   linux  /casper/vmlinuz quiet autoinstall ds=nocloud\;s=/cdrom/server/ ---
   initrd /casper/initrd
}
 Save
Add the cloud-init files as follows (the encrypted password is "ubuntu"):

mkdir new/server
touch new/server/meta-data
cat << _EOF_ > new/server/user-data
#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: ubuntu-server
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu
 Save
Create a new ISO (the output of -report_el_torito for your ISO may differ; edit accordingly)

xorriso -as mkisofs --modification-date='2021101314195100' --grub2-mbr --interval:local_fs:0s-15s:zero_mbrpt,zero_gpt:'ubuntu.iso' --protective-msdos-label -partition_cyl_align off -partition_offset 16 --mbr-force-bootable -append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b --interval:local_fs:2470124d-2478587d::'ubuntu.iso' -part_like_isohybrid -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_start_617531s_size_8464d:all::' -no-emul-boot -boot-load-size 8464 -isohybrid-gpt-basdat -o ubuntu-autoinstall.iso -V 'Ubuntu autoinstall' new/
 Save
Long version:

I started searching about subiquity, Ubuntu's new installer. I was particularly interested in finding out how they built the ISO, because I had the exact same problem you had! In its source code I came across make-edge-iso.sh which used something promising called livefs-editor. (I couldn't use that directly for what I wanted, but you'll see it offers a --add-autoinstall-config option that probably does exactly what we're after.) Digging through its code I came across the magic xorriso option "-report_el_torito as_mkisofs" which answered our questions! It attempts to tell you exactly how the ISO was built.
content_copyCOPY

https://askubuntu.com/questions/1390827/how-to-make-ubuntu-autoinstall-iso-with-cloud-init-in-ubuntu-21-10