Usage of QCow2 disk in Proxmox

karnalta

New Member
Jan 25, 2024
6
0
1
Hello all,

It's probably a dumb question but I'd like some clarifications on QCow2 file and Proxmox. I came from a a basic CentOS + KVM environment and converted it to Proxmox and I don't understand certain aspect.

- Why do I have to run "qm importdisk" on qcow2 file before being able to use it. They should simply be visible while being on a proxmox storage pool, no ?
- Moreover, why does it take as much time as if it was writing/reading it fully from scratch. The file is already in the correct format, no ?
- And even more harder to understand for me, why if I run several time "qm importdisk" on the same qcow2 file, I end up with multiple unused disk in the VM. There are pointing on the same physical files.

Bonus : Can I see the size and/or the physical file name of an unused disk inside Proxmox, cause I have several of them, and I need to reattach them to the VM in the correct order.

Thank for help !
 
Depending on the underlying storage, the disk images are not stored in files at all but as block devices, for example LVM, ZFS, RBD, …

The qm disk import command will convert the source file to whatever target format is needed, depending on the storage it is importing to.

If your storage is file based (directory, any network share), PVE expects a certain directory structure and naming scheme for the disk images images/{vmid}/vm-{vmid}-…. The default name used by Proxmox VE itself is vm-{vmid}-disk-{x} with potentially a file extension. Though you could rename the files to anything you want after the vm-{vmid}- part.

Then either change it in the VM config file or, let PVE rescan the storage for disk images belonging to that VM: qm rescan. Optionally you can provide the VMID to only search for disk images belonging to that specific VM: qm rescan --vmid {vmid}.
 
  • Like
Reactions: karnalta
Depending on the underlying storage, the disk images are not stored in files at all but as block devices, for example LVM, ZFS, RBD, …

The qm disk import command will convert the source file to whatever target format is needed, depending on the storage it is importing to.

If your storage is file based (directory, any network share), PVE expects a certain directory structure and naming scheme for the disk images images/{vmid}/vm-{vmid}-…. The default name used by Proxmox VE itself is vm-{vmid}-disk-{x} with potentially a file extension. Though you could rename the files to anything you want after the vm-{vmid}- part.

Then either change it in the VM config file or, let PVE rescan the storage for disk images belonging to that VM: qm rescan. Optionally you can provide the VMID to only search for disk images belonging to that specific VM: qm rescan --vmid {vmid}.
Storage is a ZFS pool, I had no trouble to import it back in Proxmox from my previous CentOS installation. They were lying on a ZFS file system in a zpool. So they were files not block, right ? (I am really no Linux expert).

But I do see now that the qm convertion did create block device on my zpool.. I was wondering what that "long" convertion was doing because I didn't see any new files on my pool. So basically, you cannot work with qcow2 file in proxmox ? it require block device ?

EDIT :

I just found the answer of my last question on anothher thread on this forum.
1) File device - Add ZFS pool as a directory
2) Block device - Add ZFS pool as type ZFS


I did add my storage as ZFS, that's why it automatically create block device.
 
Last edited:
So basically, you cannot work with qcow2 file in proxmox ? it require block device ?
Take a look at the documentation, some storage types work with files and for them qcow2 is an option: https://pve.proxmox.com/pve-docs/pve-admin-guide.html#chapter_storage

For ZFS, the situation is a bit more complicated. ZFS can have file system datasets and volume datasets which provide a block device. Container images are stored as file system datasets and VM images as volume (zvol) datasets.

In case disk images aren't stored in files, the handling of snapshots is done by the storage layer underneath. In your case, where the VMs are stored on ZFS, creating a VM snapshot will result in a ZFS snapshot on the zvol used for the VM.
 
  • Like
Reactions: karnalta
You do not need to import the file. If using ext4 storage. Create an empty disk qcow of the same size and attach to the vm. Use winscp to open the host and copy across your qcow disk to the same folder eg /mnt/pve/dev-sdb/images/103/Win10Base.qcow2. Delete the empty one and rename your disk with same name. Bingo.
 
  • Like
Reactions: karnalta

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!