|
| 1 | +```markdown |
| 2 | +# UTMStack / Server Autoinstall ISO |
| 3 | + |
| 4 | +## Introduction |
| 5 | + |
| 6 | +With the release of Ubuntu 20.04, the server autoinstall method changed. Previously, the Debian pre-seed method |
| 7 | +was used. The new autoinstall method uses a "user-data" file, similar to what is done with cloud-init. |
| 8 | +The Ubuntu installer, ubiquity, was modified for this and became subiquity (server ubiquity). |
| 9 | + |
| 10 | +The autoinstall "user-data" YAML file is a superset of the cloud-init user-data file and contains directives |
| 11 | +for the install tool curtin. |
| 12 | + |
| 13 | +## Step 0: Pre-requisites |
| 14 | + |
| 15 | +To build the autoinstall ISO on an Ubuntu 22.04.4 system, you will need the following packages: |
| 16 | + |
| 17 | +- **7z**: `sudo apt install p7zip` for unpacking the source ISO (including mbr and efi partition images) |
| 18 | +- **wget**: `sudo apt install wget` to download a fresh daily build of the 22.04 service ISO |
| 19 | +- **xorriso**: `sudo apt install xorriso` for building the modified ISO |
| 20 | + |
| 21 | +Two of the biggest sources of trouble when creating the user-data file for an autoinstall ISO are: |
| 22 | + |
| 23 | +- Syntax mistakes in user-data. |
| 24 | +- Misconfigured YAML. |
| 25 | + |
| 26 | +## Step 1: Set up the build environment, create a directory to work in and get a fresh copy of the server ISO: |
| 27 | + |
| 28 | +mkdir -p ISO/source-files |
| 29 | +cd ISO |
| 30 | +wget https://cdimage.ubuntu.com/ubuntu-server/jammy/daily-live/current/jammy-live-server-amd64.iso |
| 31 | +cd ISO/source-files |
| 32 | + |
| 33 | +## Step 2: Unpack files and partition images from the Ubuntu 22.04 live server ISO |
| 34 | + |
| 35 | +The Ubuntu 22.04 server ISO layout differs from the 20.04 ISO. 20.04 used a single partition on the ISO but 22.04 |
| 36 | +has separate gpt partitions for mbr, efi, and the install root image, 7zip is very useful for unpacking the ISO |
| 37 | +since it will create image files for the mbr and efi partitions for you: |
| 38 | + |
| 39 | +7z -y x jammy-live-server-amd64.iso -osource-files |
| 40 | + |
| 41 | +In the source-files directory, you will see the ISO files plus a directory named '[BOOT]'. This directory contains |
| 42 | +the files `1-Boot-NoEmul.img` and `2-Boot-NoEmul.img` which are, respectively, the mbr (master boot record) and |
| 43 | +efi (UEFI) partition images from the ISO. These will be used when we create the modified ISO. There is no reason to |
| 44 | +leave the raw image files on the new ISO, so move them out of the way and give the directory a better name: |
| 45 | + |
| 46 | +mv '[BOOT]' ../BOOT |
| 47 | + |
| 48 | +## Step 3: Edit the ISO grub.cfg file |
| 49 | + |
| 50 | +Copy the `grub.cfg` to `source-files/boot/grub/grub.cfg`: |
| 51 | + |
| 52 | +...add the directory for the user-data and meta-data files |
| 53 | + |
| 54 | +mkdir -p ISO/source-files/server |
| 55 | + |
| 56 | +Note; you can create other directories to contain alternative user-data file configurations and add extra grub menu |
| 57 | +entries pointing to those directories. That way you could have multiple install configurations on the same ISO and |
| 58 | +select the appropriate one from the boot menu during install. |
| 59 | + |
| 60 | +## Step 4: Create and add your custom autoinstall user-data files |
| 61 | + |
| 62 | +This is where you will need to read the documentation for the user-data syntax and format. I will provide a sample |
| 63 | +file to get you started. |
| 64 | + |
| 65 | +`Note; the meta-data file is just an empty file that cloud-init expects to be present (it would be populated with data |
| 66 | +needed when using cloud services)` |
| 67 | + |
| 68 | +touch source-files/server/meta-data && source-files/server/user-data |
| 69 | + |
| 70 | +## Step 5: Generate a new Ubuntu 22.04 server autoinstall ISO |
| 71 | + |
| 72 | +The following command is helpful when trying to setup the arguments for building an ISO. It will give flags and data |
| 73 | +to closely reproduce the source base install ISO. |
| 74 | + |
| 75 | +./iso-build.sh |
| 76 | + |
| 77 | +The partition images that 7z extracted for us are being added back to the recreated ISO. |
| 78 | + |
0 commit comments