If you are in need to auto-install Ubuntu to a device/VM with pre-defined config & packages - this repo explains, how to do that.
Bash script create_autoinstall_image.sh is downloading Ubuntu server 24 and do all necessary steps, to create a new autoinstall ISO image. Main configuration of your image is done via file user-data and env.sh will hold config for machine like username and password.
After creation script ran, an ISO file is sitting in folder autoinstall_image. This you can then put on an USB stick and autoinstall with that any computer.
If you want to test ISO with a virtual machine, you can use KVM/Qemu to do so. Please note, that you need to copy ISO to the configured storage pools in your configuration.
virsh pool-listThe following command shows how to start a VM and using created ISO to auto-install Ubuntu:
virt-install -n auto-install-test \
--description "VM to test Ubuntu auto install" \
--os-type=Linux --os-variant=ubuntu24.04 \
--ram=2048 --vcpus=2 \
--disk path=/path/to/diskfolder/autoinstall-test.img,bus=virtio,size=15 \
--graphics spice \
--cdrom /path/to/imagefolder/ubuntu-24.04-server-autoinstall.iso Boot image creation is done by the following steps:
-
Install xorriso with sudo apt update && sudo apt install xorriso
-
Download base image (e.g. Ubuntu server)
-
Extract ISO file to a folder on your disk
# extract original ISO xorriso -osirrox on -indev ~/Downloads/ISO/ubuntu-24.04.2-live-server-amd64.iso --extract_boot_images source-files/bootpart -extract / source-files
-
Add auto install configuration to folder nocloud into extracted ISO
-
Copy file user-data to folder nocloud
-
Create empty file meta-data in folder nocloud
-
Add option to grub.cfg (boot/grub/grub.cfg) like so:
menuentry "Start Ubuntu Autoinstall" { set gfxpayload=keep linux /casper/vmlinuz quiet autoinstall ds=nocloud\;s=/cdrom/nocloud/ --- initrd /casper/initrd }
-
Create new ISO image
xorriso -as mkisofs -r -V "ubuntu-autoinstall" -J -boot-load-size 4 -boot-info-table -input-charset utf-8 -eltorito-alt-boot -b bootpart/eltorito_img1_bios.img -no-emul-boot -o ../pod_autoinstall.iso .
-
Test with VM