Skip to content

Commit 6650b0e

Browse files
authored
UTMStack / Server Autoinstall ISO (#682)
Fix VLAN error caused by incorrect default interface configuration
1 parent f5ebdba commit 6650b0e

File tree

10 files changed

+207
-11
lines changed

10 files changed

+207
-11
lines changed

etc/iso/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+

etc/iso/crontab

Lines changed: 0 additions & 1 deletion
This file was deleted.

etc/iso/install.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

etc/iso/iso-build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
cd /home/utmstack/ISO/
4+
xorriso -indev jammy-live-server-amd64.iso -report_el_torito as_mkisofs
5+
cd source-files
6+
xorriso -as mkisofs -r \
7+
-V 'Ubuntu 22.04 LTS AUTO (EFIBIOS)' \
8+
-o ../utmstack-v10-4-0-autoinstall.iso \
9+
--grub2-mbr ../BOOT/1-Boot-NoEmul.img \
10+
-partition_offset 16 \
11+
--mbr-force-bootable \
12+
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b ../BOOT/2-Boot-NoEmul.img \
13+
-appended_part_as_gpt \
14+
-iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \
15+
-c '/boot.catalog' \
16+
-b '/boot/grub/i386-pc/eltorito.img' \
17+
-no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info \
18+
-eltorito-alt-boot \
19+
-e '--interval:appended_partition_2:::' \
20+
-no-emul-boot \
21+
.
22+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
set timeout=30
2+
3+
loadfont unicode
4+
5+
set menu_color_normal=white/black
6+
set menu_color_highlight=black/light-gray
7+
8+
menuentry "Install UTMStack Server v10-4-0" {
9+
set gfxpayload=keep
10+
linux /casper/vmlinuz quiet autoinstall ds=nocloud\;s=/cdrom/server/ ---
11+
initrd /casper/initrd
12+
}
13+
grub_platform
14+
if [ "$grub_platform" = "efi" ]; then
15+
menuentry 'Boot from next volume' {
16+
exit 1
17+
}
18+
menuentry 'UEFI Firmware Settings' {
19+
fwsetup
20+
}
21+
else
22+
menuentry 'Test memory' {
23+
linux16 /boot/memtest86+.bin
24+
}
25+
fi

etc/iso/source-files/server/meta-data

Whitespace-only changes.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#cloud-config
2+
autoinstall:
3+
version: 1
4+
refresh-installer:
5+
update: yes
6+
interactive-sections:
7+
- storage
8+
storage:
9+
layout:
10+
name: direct
11+
locale: en_US.UTF-8
12+
keyboard:
13+
layout: us
14+
identity:
15+
hostname: UTMStackServer
16+
password: "$6$d4b3b076eab83a8d$RQisa1lg.pKg9T2AAyDWXiI41/46rn6HcPdNMt4AVUNvCErbCV7UdMRTDtC7cex8UjvBzY9I6qTUvLrcZPRKo1"
17+
username: utmstack
18+
ssh:
19+
allow-pw: true
20+
install-server: true
21+
apt:
22+
sources:
23+
ignored1: # This is here to get the yaml formatting right when adding a ppa
24+
source: ppa:graphics-drivers/ppa
25+
packages:
26+
- build-essential
27+
- network-manager
28+
- dkms
29+
- emacs-nox
30+
package_update: true
31+
package_upgrade: true
32+
late-commands:
33+
# Changing from networkd to NetworkManager
34+
# move existing config out of the way
35+
- find /target/etc/netplan/ -name "*.yaml" -exec sh -c 'mv "$1" "$1-orig"' _ {} \;
36+
# Create a new netplan and enable it
37+
- |
38+
cat <<EOF | sudo tee /target/etc/netplan/01-netcfg.yaml
39+
network:
40+
version: 2
41+
renderer: NetworkManager
42+
EOF
43+
- curtin in-target --target /target netplan generate
44+
- curtin in-target --target /target netplan apply
45+
- curtin in-target --target /target systemctl enable NetworkManager.service
46+
user-data:
47+
runcmd:
48+
- wget https://cdn.utmstack.com/iso/start.sh -O /home/utmstack/start.sh && chmod +x /home/utmstack/start.sh && cd /home/utmstack/ && bash start.sh > /home/utmstack/installer.log
49+
- wget https://cdn.utmstack.com/iso/finish-install-setup.sh -O /home/utmstack/finish-install-setup.sh && chmod +x /home/utmstack/finish-install-setup.sh
50+
- |
51+
#!/usr/bin/env bash
52+
echo ''
53+
echo '********************************************************'
54+
echo ' - Default Username: utmstack '
55+
echo ' - Default Password: utmstack '
56+
echo 'sudo cd /home/utmstack/ && chmod +x start.sh && start.sh'
57+
echo '********************************************************'
58+
echo ''
59+

etc/iso/sudoers

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
echo *************************
3+
echo **** Finish Setup ****
4+
echo *************************
5+
echo 'Enter the hostname for this system: '
6+
read NEW_HOSTNAME
7+
hostnamectl set-hostname \${NEW_HOSTNAME}
8+
echo
9+
echo 'Enter the timezone for this system: '
10+
echo 'America/Los_Angeles America/Denver America/Chicago America/New_York'
11+
read NEW_TIMEZONE
12+
timedatectl set-timezone \${NEW_TIMEZONE}
13+
echo *************************
14+
echo
15+
echo *************************
16+
echo 'Restarting to finish ...'
17+
shutdown -r 3

etc/iso/tools/start.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
cd /home/utmstack/
3+
rm installer
4+
wget http://github.com/utmstack/UTMStack/releases/latest/download/installer
5+
chmod +x installer
6+
./installer

0 commit comments

Comments
 (0)