Relay70

ProxMox Cloud Template

Steps to importing a Cloud Template into ProxMox.  We will be using Rocky 9 for this demo.  However, any Linux Cloud template should work.

Download Image

Commands
wget https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base-9.5-20241118.0.x86_64.qcow2
Explanation
1 - Simple wget to download the image.
***You will need to locate the image for whatever distro and version you want to use***

Create Template

Commands
qm create 9000 --memory 2048 --name rocky9.5-CI --net0 virtio,bridge=vmbr0 --ostype l26 --cpu host --serial0 socket --vga serial0

Explanation
1 - This creates a mostly empty VM configuration
  • “9000” is simply the ProxMox ID for the VM. This separates the template ID from the normal VM ID’s ProxMox will assign.
  • “–memory 2048” sets memory to 2G. A good start that can be changed when using the Template to create VMs.
  • “–name rocky9.5-CI” set the name of the Template. Name yours however you’d like.
  • “–net0 virtio,bridge=vmbr0” set some default network device configs.
  • “–ostype l26” sets the OS type to be “Linux 6.x – 2.6 Kernel”
  • “–cpu host” sets the CPU type to whatever your ProxMox host is running.
  • “–serial0 socket –vga serial0” sets the console so we can see boot up messages.

Import Image to Template

Commands
qm importdisk 9000 Rocky-9-GenericCloud-Base-9.5-20241118.0.x86_64.qcow2 local_lvm
Explanation
1 - Imports the download image into ProxMox and attaches it to the given Template ID.
***Note: The last line has the location and name of the disk. Something like this: Successfully imported disk as 'unused0:local_lvm:vm-9000-disk-0' ***
  • “9000” gives the Template ID to attache the image to.
  • “Rocky-9-GenericCloud” is which image file to use.
  • “local_lvm” is the ProxMox Storage location to use. It can be any storage you have configured for the use of VM disk storage. local_lvm is the default ProxMox configures.

Attach Disk Image to Template

Commands
qm set 9000 --scsihw virtio-scsi-pci --scsi0 local_lvm:vm-9000-disk-0
Explanation
1 - Attached the disk to the Template.
  • “9000” specifies the VMID
  • “–scsihw virtio-scsi-pci” sets the disk hardware type
  • “–scsi0 local_lvm:vm-9000-disk-0” sets scsi disk 0 the image uploaded in the previous command.

Set Cound Init drive/Set Boot Disk

Commands
qm set  9000 --ide2 local_lvm:cloudinit
qm set 9000 --boot c --bootdisk scsi0
Explanation
1 - Creates and attaches Cloud Init drive for the Template.
2 - Configures the boot disk to be "c" and scsi0.

Change to Template

Commands
qm set 9000 --template 1
Explanation
1 - Changes VM to be a template
***Up until now what we've been building has officially been a VM. We've now turned it into a Template***
You should now have a Cloud Init enabled Template that can be used to clone new VMs from.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *