# Minimal Cloud Images ## Cloud-Init Image How to prepare a cloud-init image. ### Ubuntu 20.04 Download the latest version of the base image to one of your proxmox nodes: ``` curl -sSL https://cloud-images.ubuntu.com/minimal/releases/focal/release/ubuntu-20.04-minimal-cloudimg-amd64.img >/tmp/ubuntu-20.04-minimal-cloudimg-amd64.img ``` Create a cloud-init config to bootstrap the template: ``` cat <<'EOF'> /var/lib/vz/snippets/9003_bootstrap #cloud-config package_update: true package_upgrade: true ntp: enabled: true servers: ["pool.ntp.org"] ntp_client: systemd-timesyncd ssh_deletekeys: true ssh_genkeytypes: ["ed25519", "rsa"] bootcmd: - | sed -i 's/ENABLED=1/ENABLED=0/' /etc/default/motd-news systemctl disable motd-news.service motd-news.timer --now runcmd: - | curl -sSL https://git.giftfish.de/ston1th/cleanup/raw/branch/master/ubuntu_2004_min.sh >/tmp/cleanup.sh [ "$(sha256sum /tmp/cleanup.sh|cut -d" " -f1)" = "9fbd939eb8d1ef6157a61bb984a5045339ce361596b8a99a8847280cc785b726" ] && sh /tmp/cleanup.sh || echo "error: cleanup script hash does not match" >&2 power_state: mode: poweroff EOF ``` Create the template VM: ``` qm stop 9003; qm destroy 9003 qm create 9003 --name ubuntu-2004-min --memory 2048 --net0 virtio,bridge=vmbr0 qm importdisk 9003 /tmp/ubuntu-20.04-minimal-cloudimg-amd64.img local qm set 9003 --scsihw virtio-scsi-pci --scsi0 local:9003/vm-9003-disk-0.raw qm set 9003 --ide0 local:cloudinit qm set 9003 --boot c --bootdisk scsi0 qm set 9003 --serial0 socket --vga serial0 qm set 9003 --cicustom "user=local:snippets/9003_bootstrap" qm set 9003 --ipconfig0 ip=dhcp,ip6=dhcp qm start 9003 sleep 10;while :; do qm status 9003|grep -q stopped && break; done qm set 9003 --cicustom "" qm set 9003 --ipconfig0 "" qm template 9003 ```