Skip to content

Instantly share code, notes, and snippets.

@NickBouwhuis
Last active November 27, 2023 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickBouwhuis/94245037b8d4e2ada3f02154bf093c63 to your computer and use it in GitHub Desktop.
Save NickBouwhuis/94245037b8d4e2ada3f02154bf093c63 to your computer and use it in GitHub Desktop.
#!/bin/bash
# download the image
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img -O /tmp/jammy-server-cloudimg-amd64.img
# create a new VM
qm create 9001 --name ubuntu --memory 2048 --net0 virtio,bridge=vmbr0
# import the downloaded disk to local-lvm storage
qm importdisk 9001 /tmp/jammy-server-cloudimg-amd64.img local-lvm
# finally attach the new disk to the VM as scsi drive
qm set 9001 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9001-disk-0
# add cloud-init config
qm set 9001 --ide2 local-lvm:cloudinit
qm set 9001 --boot c --bootdisk scsi0
qm set 9001 --serial0 socket --vga serial0
# make it a template
qm template 9001
# remove the image from disk
rm /tmp/jammy-server-cloudimg-amd64.img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment