Last active
November 27, 2023 12:01
-
-
Save NickBouwhuis/94245037b8d4e2ada3f02154bf093c63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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