Create an Ubuntu 24.04 Desktop Autoinstall ISO Image

 by 

 in 

Prerequisites

apt install 7zip xorriso whois

Unpack Files and Partition Images from ISO

mkdir autoinstall-iso
cd autoinstall-iso
7z -y x ~/Downloads/ubuntu-24.04.1-desktop-amd64.iso
mv \[BOOT\] ../BOOT

Edit the ISO grub.cfg file

Set grub timeout to 3s.

set timeout=3

Add new menu entry above existing menu entries in autoinstall-iso/boot/grub/grub.cfg.

menuentry "Autoinstall Ubuntu" {
        set gfxpayload=keep
        linux   /casper/vmlinuz  --- quiet splash autoinstall ds=nocloud\;s=/cdrom/autoinstall/
        initrd  /casper/initrd
}

This menue entry adds the autoinstall kernel directive and the “data source” (ds) for cloud-init of type “nocloud”. s=/cdrom/autoinstall/ is reference to the directory where we will add user-data and meta-data files that contain the installer configuration yaml. /cdrom is the top level directory of the ISO.

Create Autoinstall Directory and Files

mkdir autoinstall
touch autoinstall/meta-data

Generate Password Hash

echo start123 | mkpasswd -s

autoinstall/user-data

#cloud-config
autoinstall:
  version: 1
  source:
    id: ubuntu-desktop-minimal
  identity:
    hostname: autoinstall
    password: $y$j9T$MYuc23vJIEA6BBnpY1y001$0FMBxaFV/5xumNOTq9o.AG68KRe9wVYhvVoSUsi75L2
    username: erwin
  locale: en_US.UTF-8
  keyboard:
    layout: de
    variant: nodeadkeys
  storage:
    layout:
      name: lvm
      sizing-policy: all
      password: start123
      match:
        size: largest  
  timezone: Europe/Berlin
  packages:
    - ansible
    - sshpass
    - bzip2
  ssh:
    install-server: true
    allow-pw: true

Generate a new Autoinstall ISO

The following command is helpful when trying to setup the arguments for building an ISO. It will give flags and data to closely reproduce the source base install ISO.

xorriso -indev ~/Downloads/ubuntu-24.04.1-desktop-amd64.iso -report_el_torito as_mkisofs

Editing the report to come up with the command for creating the autoinstall ISO.

xorriso -as mkisofs -f \
-V 'Ubuntu 24.04.1 LTS AUTOINSTALL' \
-o ../ubuntu-24.04.1-desktop-autoinstall-amd64.iso \
--grub2-mbr ../BOOT/1-Boot-NoEmul.img \
-partition_offset 16 \
--mbr-force-bootable \
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b ../BOOT/2-Boot-NoEmul.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 \
.

Based on this article:
https://www.pugetsystems.com/labs/hpc/ubuntu-22-04-server-autoinstall-iso/