[SOLVED] Errors following doc: Preparing Cloud-Init Templates

Michel V

Well-Known Member
Jul 5, 2018
32
1
48
124
Hey,

I'm following the docs on creating a cloud-init template via cli, and ran into some errors. Maybe it's me, maybe others can check as well.

USER@HOST: user with root privs on current pve


Code:
 /var/lib/vz/template/iso # wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
(OK)

Code:
/var/lib/vz/template/iso # qm create 9000 --memory 2048 --net0 virtio,bridge=vmbr0
(OK)
Code:
 /var/lib/vz/template/iso # qm importdisk 9000 bionic-server-cloudimg-amd64.img local-lvm
storage 'local-lvm' does not exists
Change local-lvm to local
Code:
/var/lib/vz/template/iso # qm importdisk 9000 bionic-server-cloudimg-amd64.img local-lvm
Configuration file 'nodes/controller/qemu-server/9000.conf' does not exist
Remove this VM with gui, rerun command that removes the error.

Code:
 /var/lib/vz/template/iso # qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9000-disk-1
storage 'local-lvm' does not exists
 /var/lib/vz/template/iso # qm importdisk 9000 bionic-server-cloudimg-amd64.img local
Formatting '/var/lib/vz/images/9000/vm-9000-disk-1.raw', fmt=raw size=2361393152
    (100.00/100%)
So here the local-lvm works does not work for me, local does

Code:
 /var/lib/vz/template/iso # qm set 9000 --scsihw virtio-scsi-pci --scsi0 local:vm-9000-disk-1
unable to parse directory volume name 'vm-9000-disk-1'
/var/lib/vz/template/iso # qm set 9000 --scsihw virtio-scsi-pci --scsi0 local:9000/vm-9000-disk-1
unable to parse volume filename 'vm-9000-disk-1'
First change does not work.

What works is to only use the id:
Code:
/var/lib/vz/images/9000 # qm set 9000 --scsihw virtio-scsi-pci --scsi0 local:9000
update VM 9000: -scsi0 local:9000 -scsihw virtio-scsi-pci
Formatting '/var/lib/vz/images/9000/vm-9000-disk-2.raw', fmt=raw size=9663676416000
Note that then also

Code:
qm set 9000 --ide2 local-lvm:cloudinit
fails, you need local in there as well.

Again: it might be me, but maybe it helps others.
 
Last edited:
Hey, nothing special (I presume):

dir: backup
path /var/lib/vz/
content backup
maxfiles 10
shared 0

dir: local
path /var/lib/vz
content vztmpl,images,rootdir,iso
maxfiles 0
 
Yes, hence my notes here to change the settings. And maybe more people encounter this, and are reading the docs for it. So hopefully it is useful for someone...
 
Hi guys, sorry for waking up an old thread but I'm facing a very similar problem...

I'm also trying to set up a Ubuntu Cloud image template using Cloud init.
I'm hoping to use the "directory" because it's consistent with all the nodes in my cluster and should allow for migration of VMs from one node to another.

First I create the VM:

/etc/pve/storage.cfg:
dir: local path /var/lib/vz content vztmpl,backup,iso zfspool: local-zfs pool rpool/data content rootdir,images nodes pve-rickblaine sparse 1 dir: directory path /vms content images prune-backups keep-all=1 shared 0

So I create the VM:
qm create 8000 --memory 8000 --name ubuntu-cloud --net0 virtio,bridge=vmbr99

Then I try to import the disk:

qm importdisk 8000 jammy-server-cloudimg-amd64.img directory

Similar to OP, it successfully imports but as a .raw image:

Successfully imported disk as 'unused0:directory:8000/vm-8000-disk-0.raw'

If I attach the vm using either the UI in Proxmox or qm set 8000 --scsihw virtio-scsi-pci --scsi0 directory:8000 It attaches but it results in non-bootable server.

Same happens if I convert the image qcow2 when importing the disk, no difference

If I do the same commands but use my storage "local-zfs" it works no problem.

First, it doesn't import the disk as a raw image: Successfully imported disk as 'unused0:local-zfs:vm-8000-disk-0'

then

qm set 8000 --scsihw virtio-scsi-pci --scsi0 local-zfs:vm-8000-disk-0 update VM 8000: -scsi0 local-zfs:vm-8000-disk-0 -scsihw virtio-scsi-pci

Works as expected. The resulting template works perfectly fine.

I have the exact same problem if I wanted to use the "local" storage.

There must be something I'm missing what's the difference between "local", "directory" and "local-zfs"... ?
I'm able to use "directory" no problem when manually creating VMs in the UI

Any help greatly appreciated :)
 
If I attach the vm using either the UI in Proxmox or qm set 8000 --scsihw virtio-scsi-pci --scsi0 directory:8000 It attaches but it results in non-bootable server.
thats not the name or path of the disk that you imported.
It should be something like:
qm set 8000 --scsihw virtio-scsi-pci --scsi0 directory:8000/vm-8000-disk-0.raw

when in doubt - get a list of disks and their paths:
pvesm list directory


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
ahhh, so interesting, yes it worked with the revised format:

qm set 8000 --scsihw virtio-scsi-pci --scsi0 directory:8000/vm-8000-disk-0.raw

And I confirm my template+cloud init seems all good as expected.

Thanks a lot :)
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!