Ubuntu autoinstall

HowTo
https://ubuntu.com/server/docs/install/autoinstall-quickstart?_ga=2.43495907.737493104.1708712193-1301017873.1682412256

Prepare

sudo apt install qemu-system-x86
sudo mount -r ~/Downloads/ubuntu-22.04.4-live-server-amd64.iso /mnt
<code>
 
<strong>Download Server Live iso</strong>
https://releases.ubuntu.com/21.04/ubuntu-21.04-live-server-amd64.iso
<code>
wget https://releases.ubuntu.com/21.10/ubuntu-21.10-live-server-amd64.iso -O ubuntu-21.10-live-server-amd64.iso

Copy files (to GRML boot USB pen)

fuseiso Downloads/iso/ubuntu-21.10-live-server-amd64.iso /tmp/iso/
#mount -o loop isofilename.iso /mnt/iso
 
mkdir /media/${USER}/GRML/boot/ubuntu/u2010/
cp /tmp/iso/casper/initrd /media/${USER}/GRML/boot/ubuntu/u2010/initrd
cp /tmp/iso/casper/vmlinuz /media/${USER}/GRML/boot/ubuntu/u2010/vmlinuz
cp Downloads/iso/ubuntu-21.10-live-server-amd64.iso /media/${USER}/GRML/boot/ubuntu/u2010/
umount /tmp/iso

Grub (UEFI)

# /boot/grub/grml64small_default.cfg
menuentry "Ubuntu autoinstall Ubuntu 21.10 server" {
    linux /boot/ubuntu/u2010/vmlinuz boot=casper iso-scan/filename=/boot/ubuntu//u2010/ubuntu-21.10-live-server-amd64.iso ip=dhcp autoinstall ds=nocloud-net\;s=http://dl.panticz.de/autoinstall/
    initrd /boot/ubuntu/u2010/initrd 
}
 
#menuentry "Ubuntu autoinstall" {
#    linux /boot/ubuntu/vmlinuz boot=casper iso-scan/filename=/boot/ubuntu/ubuntu-21.04-live-server-amd64.iso ip=dhcp autoinstall ds=nocloud-net\;s=http://dl.panticz.de/autoinstall/
#    initrd /boot/ubuntu/initrd 
#}

Pxelinux

label ubuntu
  menu DEFAULT
  menu label Ubuntu autoinstall
  kernel /boot/ubuntu/vmlinuz
  append initrd=/boot/ubuntu/initrd boot=casper iso-scan/filename=/boot/ubuntu/ubuntu-21.04-live-server-amd64.iso only-ubiquity ip=dhcp root=/dev/ram0 autoinstall ds=nocloud-net;s=http://dl.panticz.de/autoinstall/

user-data

#cloud-config
autoinstall:
  version: 1
  locale: en_US.UTF-8
  keyboard:
    layout: de
  identity:
    hostname: u2104
    username: root
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0" # ubuntu
  ssh:
    install-server: yes
    allow-pw: no
    # authorized-keys:
    #   - "ssh-rsa xxxxxxxxxx foo-key"
  apt:
    geoip: true
  # storage:
  #   layout:
  #     name: lvm
  late-commands:
    - curtin in-target --target=/target -- apt update
    - curtin in-target --target=/target -- apt upgrade -y
    - curtin in-target --target=/target -- apt autoremove -y
    - curtin in-target --target=/target -- ssh-import-id-gh panticz
 
  # proxy: http://squid.internal:3128/
touch meta-data
touch vendor-data
 
# start webserver
python3 -m http.server 3003

VM
https://ubuntu.com/server/docs/install/autoinstall-quickstart

# create
truncate -s 10G image.img && kvm -m 1024 \
  -drive file=image.img,format=raw,cache=none,if=virtio \
  -cdrom ~/Downloads/iso/ubuntu-21.04-live-server-amd64.iso \
  -kernel "/media/pako/Ubuntu-Server 21.04 amd64/casper/vmlinuz" \
  -initrd "/media/pako/Ubuntu-Server 21.04 amd64/casper/initrd" \
  -append 'autoinstall ds=nocloud-net;s=http://_gateway:3003/'
 
# allow access to bridgte
sudo mkdir /etc/qemu
echo "allow lxdbr0" | sudo tee /etc/qemu/bridge.conf
 
# start VM connected to bridge lxdbr0
sudo kvm -m 1024 \
  -drive file=image.img,format=raw,cache=none,if=virtio \
  -device virtio-net-pci,netdev=net0 \
  -netdev bridge,id=net0,br=lxdbr0
 
# get VM IP
nmap -sP 192.168.1.*

Links
https://ubuntu.com/server/docs/install/autoinstall-reference
https://ubuntu.com/server/docs/install/autoinstall-schema
https://cloudinit.readthedocs.io/en/latest/topics/modules.html
https://curtin.readthedocs.io/en/latest/