Testing Ubuntu autoinstall
Testing autoinstall with ubuntu server
Testing Ubuntu autoinstall
🔧 Setup a boot and installation media (Autoinstall not working)
- Download the most recent Ubuntu server LTS
- Use Rufus and USB Key to create a Boot Media
- Once the boot media is completed, open the USB with a file manager
- Go to
/boot/grub/
directory Edit
grub.cfg
and add this line under the firstmenuentry
block:1
set autoinstall="ds=nocloud;s=/cdrom/nocloud/"
- So it looks something like:
1 2 3 4 5
menuentry "Install Ubuntu Server" { set gfxpayload=keep linux /casper/vmlinuz --- autoinstall ds=nocloud\;s=/cdrom/nocloud/ initrd /casper/initrd }
- 🧾 Create
nocloud
Directory with Config In the root of your USB (same level asboot/
,casper/
), create a new folder:1
/nocloud/
- Create
user-data
, copy and complete the script bellow- SSH-only access
- Docker & Compose ready
- UFW firewall with OpenSSH & NGINX allowed
- NVIDIA drivers and GPU container support
- Auto-start Docker & secure SSH config
- Replace the
and tags with yours
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#cloud-config
autoinstall:
version: 1
identity:
hostname: <user_name>-server
username: <user_name>
password: "" # No password
ssh:
install-server: true
authorized-keys:
- <public_ssh_key>
storage:
layout:
name: direct
packages:
- docker.io
- git
- curl
- ufw
- software-properties-common
- nvidia-driver-570-server # Adjust if using a different version
user-data:
disable_root: true
ssh_pwauth: false
users:
- name: <user_name>
groups: [sudo, docker]
shell: /bin/bash
lock_passwd: true
sudo: ALL=(ALL) NOPASSWD:ALL
ssh_authorized_keys:
- <public_ssh_key>
late-commands:
# Enable Docker at boot
- curtin in-target -- systemctl enable docker
# Install Docker Compose (latest version)
- curtin in-target -- bash -c "curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose"
- curtin in-target -- chmod +x /usr/local/bin/docker-compose
# Setup UFW
- curtin in-target -- ufw allow OpenSSH
- curtin in-target -- ufw allow 'Nginx Full'
- curtin in-target -- ufw --force enable
# Harden SSH
- curtin in-target -- sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
# Install NVIDIA Docker runtime (for container GPU support)
- curtin in-target -- bash -c "distribution=$(. /etc/os-release; echo $ID$VERSION_ID) && \
curl -s -L https://nvidia.github.io/libnvidia-container/gpgkey | gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit.gpg && \
curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit.gpg] https://#' | \
tee /etc/apt/sources.list.d/nvidia-container-toolkit.list"
- curtin in-target -- apt-get update
- curtin in-target -- apt-get install -y nvidia-container-toolkit
- curtin in-target -- nvidia-ctk runtime configure --runtime=docker
- curtin in-target -- systemctl restart docker
- Create
meta-data
, copy and complete the content bellow
1
2
instance-id: <user_name>-install
local-hostname: <user_name>-server
This post is licensed under CC BY 4.0 by the author.