Instantly share code, notes, and snippets.
Save chriswayg/b6421dcc69cb3b7e41f2998f1150e1df to your computer and use it in GitHub Desktop.
- Using a ready-to-use Ubuntu image
- Ubuntu 18.04 LTS (Bionic Beaver) Daily Build
wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img# Create a VMqm create 9000 --name ubuntu1804-templ --memory 2048 --net0 virtio,bridge=vmbr1# Import the disk in qcow2 format (as unused disk)qm importdisk 9000 bionic-server-cloudimg-amd64.imglocal -format qcow2# Attach the disk to the vm using VirtIO SCSIqmset 9000 --scsihw virtio-scsi-pci --scsi0 /var/lib/vz/images/9000/vm-9000-disk-0.qcow2# Important settingsqmset 9000 --ide2 local:cloudinit --boot c --bootdisk scsi0 --serial0 socket --vga serial0# The initial disk is only 2GB, thus we make it largerqm resize 9000 scsi0 +30G# Using a dhcp server on vmbr1 or use static IPqmset 9000 --ipconfig0 ip=dhcp#qm set 9000 --ipconfig0 ip=10.10.10.222/24,gw=10.10.10.1# user authentication for 'ubuntu' user (optional password)qmset 9000 --sshkey~/.ssh/id_rsa.pub#qm set 9000 --cipassword AweSomePassword# check the cloud-init configqm cloudinit dump 9000 user# create tempalte and a linked cloneqm template 9000qm clone 9000 190 --name ubuntu1804-1qm start 190rm -v bionic-server-cloudimg-amd64.img
- Login with:
ssh ubuntu@10.10.10.190
- Using a ready-to-use Debian image
- Debian Official Cloud Images for OpenStack
wget https://cdimage.debian.org/cdimage/openstack/current/debian-10.0.2-20190721-openstack-amd64.qcow2# Create a VMqm create 9110 --name debian10-cloud --memory 2048 --net0 virtio,bridge=vmbr1# Import the disk in qcow2 format (as unused disk) qm importdisk 9110 debian-10.0.2-20190721-openstack-amd64.qcow2 local -format qcow2# Attach the disk to the vm using VirtIO SCSIqm set 9110 --scsihw virtio-scsi-pci --scsi0 /var/lib/vz/images/9110/vm-9110-disk-0.qcow2# Important settingsqm set 9110 --ide2 local:cloudinit --boot c --bootdisk scsi0 --serial0 socket --vga serial0# The initial disk is only 2GB, thus we make it largerqm resize 9110 scsi0 +30G# Using a dhcp server on vmbr1 or use static IPqm set 9110 --ipconfig0 ip=dhcp#qm set 9110 --ipconfig0 ip=10.10.10.222/24,gw=10.10.10.1# user authentication for 'debian' user (optional password)qm set 9110 --sshkey ~/.ssh/id_rsa.pub#qm set 9110 --cipassword AweSomePassword# check the cloud-init configqm cloudinit dump 9110 user# create tempalte and a linked cloneqm template 9110qm clone 9110 191 --name debian10-1qm start 191rm -v debian-10.0.2-20190721-openstack-amd64.qcow2- Login with:
ssh debian@10.10.10.191
qm shutdown 190 && qm waitqm resize 190 scsi0 +8Gqm start 190When booting undersystemd, you can disable cloud-init completely by either:
- creating a file:
sudo touch /etc/cloud/cloud-init.disabled - or adding
cloud-init=disabledto the kernel command line as found in/proc/cmdline
To partially disable some functions, modify:/etc/cloud/cloud.cfg, for example to disable network configuration:
sudo su -echo"network: {config: disabled}"> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
sudo nano /etc/default/grub config
GRUB_TERMINAL="console serial"sudo update-grub
- Cloud-init v.18.2: CLI subcommands | Ubuntu
- Directory layout — Cloud-Init 19.2 documentation
- Testing and debugging cloud-init — Cloud-Init 19.2 documentationcloud-localds(1) — cloud-image-utils — Debian testing — Debian Manpages
https://docs.openstack.org/image-guide/convert-images.html
qemu-img convert -f raw -O qcow2 bionic-server-cloudimg-amd64.img bionic-server-cloudimg-amd64.qcow2gdelanoy commentedOct 26, 2023
worked just fine.
Thanks.
FYI, following your gist with recent images also works fine.
Just
wgethttps://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-disk-kvm.img
or
wgethttps://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
and adapt the file names where needed, and you're good to go;
electropolis commentedFeb 5, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
How you manage to do this# Import the disk in qcow2 format (as unused disk) qm importdisk 9000 bionic-server-cloudimg-amd64.img local -format qcow2
Whenlocal"storage: storage 'local' does not support vm images" ?
jgkawell commentedMar 7, 2024
@electropolis You should be able to uselocal-lvm instead oflocal.