How to rename image files after using "qm importdisk"?

ams_tschoening

New Member
Jun 28, 2021
22
8
3
43
I'm migrating from VirtualBox to Proxmox and am creating the new VMs on the shell. Part of that is using "qm importdisk" to import available VMDK files as new QCOW2 ones. While that works in general, the result is a file like e.g. "encr_zfs:100/vm-100-disk-0.qcow2". While that is OK for only one disk per VM, I have multiple VMs with multiple disks in which case it would be good when looking at file names already to see which disk contains which content. It's about root vs. home vs. tmp vs. swap etc.

So, is there any option to "qm importdisk" I'm missing to provide a custom suffix for image files?

If not, what is the correct way of renaming the created image files? Simply using "mv" in the storage directory, before the disk has been attached to any VM? Or are is there any other bookkeeping involved already after importing only?

Does it make a difference which storage type is used? In my case it's an encrypted ZFS dataset, which is configured as storage type "dir" instead of ZFS in Proxmox. So Proxmox really only sees files instead of ZVOLs or alike.

Thanks!
 
Last edited:
Here is what seems to work for me:

Bash:
qm 'importdisk' "${vm_id}" "${img_src}" 'encr_zfs' '--format=qcow2'
mv "${prefix_abs}-disk-0.qcow2" "${prefix_abs}-${img_dst}"
qm    'set' "${vm_id}" --scsi0 "encr_zfs:${prefix_rel}-${img_dst}${PXMX_DISK_OPTS}"
pvesh 'set' "${PXMX_API_NODE}/qemu/${vm_id}/config" '-delete' 'unused0'

One important thing to note is that after importing the disk, an "unused0" is added to the VM referencing it. After the same file has been renamed on the shell, that "unused0" needs to be removed, as it references no actual file anymore anyway.

Bild_2021-08-03_154742.png

Would be great to have some kind of rename-API working on storage like "importdisk" does already. Or even better, if the suffix "disk-0" could simply be provided by the caller of "importdisk", at least optionally.
 
yeah, the plan is to gradually increase support for setting (and keeping) a custom suffix instead of the autogenerated '-disk-N' one. it just needs touching up in a lot of places, and with stuff like this the GUI is usually the last place where new features are exposed ;)
 
yeah, the plan is to gradually increase support for setting (and keeping) a custom suffix instead of the autogenerated '-disk-N' one.[...]
While it becomes a bot off-topic, what does "keeping" exactly mean? Persisting a suffix per VM or node or whatever wouldn't help me. I would really need to provide a suffix per created disk image and for each and every new one a different one as well. So that I can create an image being used for "root" and name it that way, or "swap" or "windows_c", "mnt_luks", "var_tmp" etc.

With VBOX I even maintained a whole image name like "org.example.some-host_root.vmdk" etc., because it had a media manager independent of VMs as well and multiple "root.vmdk" only could be easily maintained. But Proxmox already takes care of that prefix part by e.g. "100/vm-100-[...]" and I can live with that, might even be better than my former naming scheme as it's shorter. Though, having some control over an individual suffix per image would be nice.
 
keeping as in if you move the disk to another storage/format, or migrate the guest and thus re-create its local volumes on the other end, PVE should try to preserve the suffix for the newly created volume on the other storage/node.
 
  • Like
Reactions: ams_tschoening

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!