template concept

Create a template with cloud-init

Hard way

1- ssh access your proxmox
2- Use your root acount
3- Download your cloud distro image:

DEBIAN_9_URL="https://cdimage.debian.org/cdimage/openstack/current-9/debian-9-openstack-amd64.qcow2"
DEBIAN_10_URL="https://cdimage.debian.org/cdimage/openstack/current-10/debian-10-openstack-amd64.qcow2"
DEBIAN_11_URL="https://cdimage.debian.org/cdimage/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2"
UBUNTU_1804_URL="https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img"
UBUNTU_2004_URL="https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"
UBUNTU_2204_URL="https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"

E.g.

wget http://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img

4- Change file extension

mv jammy-server-cloudimg-amd64.img ubuntu-22.04.qcow2

5- Resize image

qemu-img resize ubuntu-22.04.qcow2 32G

6- Create machine on proxmox

qm create 2204 --memory 1024 --core 1 --name ubuntu-cloud --net0 virtio,bridge=vmbr0

7- Import disk and other settings

qm importdisk 2204 ubuntu-22.04.qcow2 disk1
qm set 2204 --scsihw virtio-scsi-pci --scsi0 disk1:vm-2204-disk-0
qm set 2204 --ide2 disk1:cloudinit
qm set 2204 --boot c --bootdisk scsi0
qm set 2204 --serial0 socket --vga serial0
qm set $VM_ID --agent 1

8- Cloud init settins

qm set 2204 --name 32Gubuntu-2004
qm set 2204 --ciuser myuser
qm set 2204 --sshkey ~/.ssh/id_rsa.pub
qm set 2204 --ipconfig0 ip=192.168.0.99/24,gw=192.168.0.1
qm start 2204
ssh myuser@192.168.0.99

9- apt update

apt update

10- Qemu guest agent install

apt install qemu-guest-agent && systemctl start qemu-guest-agent

11- Machine clean

truncate -s 0 /etc/machine-i && truncate -s 0 /var/lib/dbus/machine-id
rm /etc/ssh/ssh_host_*
apt-get install cloud-init && cloud-init clean
rm -r ../proxmox-template
shutdown -h now

12- Make template

qm template 2204

Easy way

1- ssh access your proxmox
2- Use your root acount
3- Script download

apt install git
git clone https://github.com/ramosgladson/proxmox-template.git
cd proxmox-template
bash vmcrate.sh

4- SSH your machine
5- Use root acount
6- Script download

apt install git
git clone https://github.com/ramosgladson/proxmox-template.git
cd proxmox-template
bash vmprepare.sh

*back to your proxmox

qm template

7- Enjoy your time!!

IMPORTANT NOTICE: This image was Image by storyset on Freepik