I recently built an unattended installation ISO to ease installation of Windows 11 test machines. So why not do the same for Ubuntu?
While looking around I found solutions for Ubuntu 20.04 and 22.04. The 22.04 version basically works fine for Ubuntu 24.04. Nothing the less some modifications were required: the key server URL was modified to use the encrypted version (with the advantage that this one does respond to queries) and the script was prepared to easier adapt to future Ubuntu versions.
The modified version can be found in my github repository.
The automatic configuration of latest Ubuntu releases is done using cloud-init (aka user-data). A sample (user-data.example) of it is available within the repository.
Detailed descriptions about its syntax can be found here:
For generic cloud-init
documentation look here:
https://cloudinit.readthedocs.io/en/stable
Information about autoinstallation using Ubuntu’s subiquity
installer look here:
https://canonical-subiquity.readthedocs-hosted.com/en/latest
user-data / cloud-init
linux # cat user-data
#cloud-config
autoinstall:
version: 1
identity:
hostname: ubuntu-server
password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
realname: "Ubuntu default user"
username: ubuntu
kernel:
flavor: hwe
keyboard:
layout: de
locale: de_DE.UTF-8
ssh:
allow-pw: true
install-server: true
source:
id: ubuntu-desktop-minimal
search_drivers: true
update: yes
updates: security
package_update: true
package_upgrade: true
package_reboot_if_required: true
timezone: Europe/Berlin
codecs:
install: true
drivers:
install: true
In order to check the syntax you can use:
linux # cloud-init schema --config-file=user-data --annotate
<...>
Valid schema user-data
And here’s an usage example converting a default Ubuntu Desktop ISO into an autoinstall / cloud-init version:
linux # ./ubuntu-autoinstall-generator.sh -s ubuntu-24.04.1-desktop-amd64.iso -k -u user-data -a -d ubuntu-24.04.1-desktop-amd64-cloudinit.iso
[2025-01-07 17:51:26] 👶 Starting up...
[2025-01-07 17:51:26] 📁 Created temporary working directory /tmp/tmp.yXXxeQitM8
[2025-01-07 17:51:26] 🔎 Checking for required utilities...
[2025-01-07 17:51:26] 👍 All required utilities are installed.
[2025-01-07 17:51:26] ☑️ Using existing ubuntu-24.04.1-desktop-amd64.iso file.
[2025-01-07 17:51:26] 🤞 Skipping verification of source ISO.
[2025-01-07 17:51:26] 🔧 Extracting ISO image...
[2025-01-07 17:51:33] 👍 Extracted to /tmp/tmp.yXXxeQitM8/iso
[2025-01-07 17:51:33] 🧩 Adding autoinstall parameter to kernel command line...
[2025-01-07 17:51:33] 👍 Added parameter to UEFI kernel command line.
[2025-01-07 17:51:33] 🧩 Setting grub timeout to 1 second...
[2025-01-07 17:51:33] 👍 Timeout set for UEFI kernel command line.
[2025-01-07 17:51:33] 🧩 Adding user-data and meta-data files...
[2025-01-07 17:51:33] 👍 Added data and configured kernel command line.
[2025-01-07 17:51:33] 👷 Updating /tmp/tmp.yXXxeQitM8/iso/md5sum.txt with hashes of modified files...
[2025-01-07 17:51:33] 👍 Updated hashes.
[2025-01-07 17:51:33] 📦 Repackaging extracted files into an ISO image...
xorriso 1.5.6 : RockRidge filesystem manipulator, libburnia project.
Drive current: -outdev 'stdio:/home/marcel/c/ubuntu-24.04-autoinstall-generator/ubuntu-24.04.1-desktop-amd64-cloudinit.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 484g free
xorriso : WARNING : -volid text does not comply to ISO 9660 / ECMA 119 rules
Added to ISO image: directory '/'='/tmp/tmp.yXXxeQitM8/iso'
xorriso : UPDATE : 1212 files added in 1 seconds
xorriso : UPDATE : 1212 files added in 1 seconds
xorriso : NOTE : Copying to System Area: 2048 bytes from file '/tmp/tmp.yXXxeQitM8/BOOT/1-Boot-NoEmul.img'
xorriso : UPDATE : 2.80% done
xorriso : UPDATE : 31.49% done
xorriso : UPDATE : 57.69% done, estimate finish Tue Jan 07 17:51:37 2025
xorriso : UPDATE : 83.63% done
ISO image produced: 3028555 sectors
Written to medium : 3028555 sectors at LBA 0
Writing to 'stdio:/home/marcel/c/ubuntu-24.04-autoinstall-generator/ubuntu-24.04.1-desktop-amd64-cloudinit.iso' completed successfully.
[2025-01-07 17:51:37] 👍 Repackaged into /home/marcel/c/ubuntu-24.04-autoinstall-generator/ubuntu-24.04.1-desktop-amd64-cloudinit.iso
[2025-01-07 17:51:37] ✅ Completed.
[2025-01-07 17:51:38] 🚽 Deleted temporary working directory /tmp/tmp.yXXxeQitM8
Internals
If you’re interested in how this script works and you risked a look at it you may wonder how the mkisofs
options came to pass. There’s to much of them to just try them, but there’s a way to get the basic options used to build an existing ISO:
linux # xorriso -report_about warning -indev ubuntu-24.04.1-desktop-amd64.iso -report_system_area as_mkisofs
xorriso 1.5.6 : RockRidge filesystem manipulator, libburnia project.
-V 'Ubuntu 24.04.1 LTS amd64'
--modification-date='2024082716232600'
--grub2-mbr --interval:local_fs:0s-15s:zero_mbrpt,zero_gpt:'ubuntu-24.04.1-desktop-amd64.iso'
--protective-msdos-label
-partition_cyl_align off
-partition_offset 16
--mbr-force-bootable
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b --interval:local_fs:12105120d-12115263d::'ubuntu-24.04.1-desktop-amd64.iso'
-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_start_3026280s_size_10144d:all::'
-no-emul-boot
-boot-load-size 10144