ZFS import cloud image to be used as template

harmonyp

Member
Nov 26, 2020
196
4
23
47
When I create a template from a cloud image I run the following
Code:
qm create 8110 --name Ubuntu20.04 --memory 2048
qm importdisk 8110 focal-server-cloudimg-amd64.img local
cd /var/lib/vz/images/8110
qemu-img convert -O qcow2 vm-8110-disk-0.raw vm-8110-disk-0.qcow2
qm set 8110 --scsihw virtio-scsi-pci --scsi0 local:8110/vm-8110-disk-0.qcow2
qm set 8110 --ide2 local:cloudinit
qm set 8110 --boot c --bootdisk scsi0
qm set 8110 --serial0 socket --vga serial0
rm -rf vm-8110-disk-0.raw
sed -i '/unused0/d' /etc/pve/qemu-server/8110.conf

But now I am using ZFS that's not possible mainly the part below

Code:
cd /var/lib/vz/images/8110
qemu-img convert -O qcow2 vm-8110-disk-0.raw vm-8110-disk-0.qcow2

How do I achieve this same outcome but with ZFS?
 
The dance with image conversion , backend delete , etc can be avoided by using the --format option as listed in in "man qm:
Code:
 qm disk import <vmid> <source> <storage> [OPTIONS]

       Import an external disk image as an unused disk in a VM. The image format has to be supported by qemu-img(1).

       <vmid>: <integer> (1 - N)
           The (unique) ID of the VM.

       <source>: <string>
           Path to the disk image to import

       <storage>: <string>
           Target storage ID

       --format <qcow2 | raw | vmdk>
           Target format

You can also avoid the "qm set" part, by doing import during the VM create:
"--scsi0 $STORAGE:0,import-from=$ISO/$OSIMAGE"




Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox