Cloud-Init Images From A Proxmox Template
Creating The Template from an IMG File
# Add IMG to Proxmox
cd /var/lib/vz/template/iso
# Note this is not an iso, but an img
wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
Creating the Cloud init Template
# create a new VM
qm create 9000 --memory 2048 --net0 virtio,bridge=vmbr2
# import the downloaded disk to local-lvm storage
# change directories to the location of the .img file to load it into local-lvm
qm importdisk 9000 bionic-server-cloudimg-amd64.img local-lvm
# finally attach the new disk to the VM as scsi drive
# Disks index at 0
qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9000-disk-0
qm set 9000 --ide2 local-lvm:cloudinit
qm set 9000 --boot c --bootdisk scsi0
qm set 9000 --serial0 socket --vga serial0
qm template 9000
In the GUI set the disk size to 32 gb, increase RAM, and set the cloud-init configuration.
Deploying from a Template
qm clone 9000 211 --name hlvkt5
qm set 211 --cicustom "meta=local:snippets/user-data.yml"
Migrating Node to Another Proxmox Host
# From node1
qm migrate 100 hlpmx2 --online --with-local-disks
After Deploying the Image via Cloud-init
Reboot the server. The server should register in DHCP and DNS and be accessible via ssh using the ubuntu
user.
Check that the server drives to ensure everything looks correct:
# lsblk
ubuntu@HLVKT4:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 55.4M 1 loop /snap/core18/1932
loop1 7:1 0 67.8M 1 loop /snap/lxd/18150
loop2 7:2 0 31.1M 1 loop /snap/snapd/10492
sda 8:0 0 32.2G 0 disk
├─sda1 8:1 0 32.1G 0 part /
├─sda14 8:14 0 4M 0 part
└─sda15 8:15 0 106M 0 part /boot/efi
sr0 11:0 1 4M 0 rom
# df -h
ubuntu@HLVKT4:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 394M 960K 393M 1% /run
/dev/sda1 32G 1.7G 30G 6% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda15 105M 3.9M 101M 4% /boot/efi
/dev/loop0 56M 56M 0 100% /snap/core18/1932
/dev/loop1 68M 68M 0 100% /snap/lxd/18150
/dev/loop2 32M 32M 0 100% /snap/snapd/10492
tmpfs 394M 0 394M 0% /run/user/1000