Skip to content

Instantly share code, notes, and snippets.

@origox
Last active June 26, 2022 20:19
Show Gist options
  • Save origox/a90a8c8124166883e30f9a40b787086f to your computer and use it in GitHub Desktop.
Save origox/a90a8c8124166883e30f9a40b787086f to your computer and use it in GitHub Desktop.
Proxmox Template with Cloud Image and Cloud Init

Introduction

Use cloud-init to configure cloud-images i.e. add SSH keys, set network settings, create users, install various packages

Cloud images are certified to run in public cloud services and as well Proxmox.

Create Proxmox Template

# SSH into Proxmox server
proxmox@proxmox:~#

# Download cloud image - Ubuntu Server 22.04(Jammy Jellyfish)
proxmox@proxmox:~# wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img

# Create new VM in Proxmox env
proxmox@proxmox:~# qm create 8000 --memory 4096 --core 2 --name ubuntu-cloud --net0 virtio,bridge=vmbr0

# Import the downloaded disk to local-lvm storage
proxmox@proxmox:~# qm importdisk 8000 focal-server-cloudimg-amd64.img local-lvm

# Attach the new disk to the VM as scsi drive(Ubuntu Cloud-Init images require the virtio-scsi-pci controller for SCSI drives)
proxmox@proxmox:~# qm set 8000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-8000-disk-0

# Add/Config Cloud-init drive(create virtual cdrom and attach that) 
proxmox@proxmox:~# qm set 8000 --ide2 local-lvm:cloudinit 

# Configure to boot from cloud init drive
proxmox@proxmox:~# qm set 8000 --boot c --bootdisk scsi0

# Add serial console
proxmox@proxmox:~# qm set 8000 --serial0 socket --vga serial0

# Configure wanted parameters, see Cloud-Init Tab in proxmox for newly created VM
## set user, ssh keys(add your public ssh key), ip config(set dhcp), ...

# Right click and convert VM to Template
## or run qm template 8000

# Create new VM from template
## qm clone 8000 125 --name apa --full
@origox
Copy link
Author

origox commented Jun 26, 2022

I can extend size of cloud template in Proxmox GUI but how to do it in terminal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment