ZFS import cloud image to be used as template

harmonyp

Member
Nov 26, 2020
196
4
23
46
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
 

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!