Skip to content

Instantly share code, notes, and snippets.

@rubi022
Created July 26, 2024 04:28
Show Gist options
  • Save rubi022/844bd80bf918ca6bff24489e51b61b51 to your computer and use it in GitHub Desktop.
Save rubi022/844bd80bf918ca6bff24489e51b61b51 to your computer and use it in GitHub Desktop.
cloud-init image creation
============================================================================================================
============================================================================================================
# download the image
wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
# create a new VM with VirtIO SCSI controller
qm create 9000 --memory 2048 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci
# import the downloaded disk to the local-lvm storage, attaching it as a SCSI drive
qm set 9000 --scsi0 local-lvm:0,import-from=/path/to/bionic-server-cloudimg-amd64.img
#Add Cloud-Init CD-ROM drive
qm set 9000 --ide2 local-lvm:cloudinit
#boot directly from harddisk
qm set 9000 --boot order=scsi0
#For many Cloud-Init images, it is required to configure a serial console and use it as a display. If the configuration doesn’t work for a given image however, switch back to the default display instead.
qm set 9000 --serial0 socket --vga serial0
#In a last step, it is helpful to convert the VM into a template. From this template you can then quickly create linked clones. The deployment from VM templates is much faster than creating a full clone (copy).
qm template 9000
============================================================================================================
============================================================================================================
wget paste_link_of_os_cloud_init_image ####search for cloudimg-amd64.img
qm create CHANGE_vm_id --memory 2048 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci
qm set CHANGE_vm_id --scsi0 local:0,import-from=[PATH_OF_cloudimg-amd64.img_] ####LOCAL IS HDD
qm set CHANGE_vm_id --ide2 local:cloudinit
qm set CHANGE_vm_id --boot order=scsi0
qm set CHANGE_vm_id --serial0 socket --vga serial0
qm template CHANGE_vm_id
@rubi022
Copy link
Author

rubi022 commented Jul 26, 2024

Link_Cloudimg =
VM_ID =

wget Link_Cloudimg ####search for cloudimg-amd64.img

qm create CHANGE_vm_id --memory 2048 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci

qm set CHANGE_vm_id --scsi0 local:0,import-from=[PATH_OF_cloudimg-amd64.img_] ####LOCAL IS HDD

qm set CHANGE_vm_id --ide2 local:cloudinit
qm set CHANGE_vm_id --boot order=scsi0
qm set CHANGE_vm_id --serial0 socket --vga serial0
qm template CHANGE_vm_id

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