Create VM from existing qcow2 image ?

niuk

New Member
Feb 20, 2017
27
0
1
55
I have qcow2 image below and want to create VM using this image ..How do I do this from GUI ? If not then from CLI. I tried to google it but hasn't found straight answer yet , same on Proxmox support pages

root@pve:/var/lib/vz/template/iso# ls -l /var/lib/vz/images/
total 1940868
-rw-r--r-- 1 root root 1987444736 Mar 1 10:10 PA-VM-KVM-8.0.0.qcow2
 

Mike_TBF

New Member
Feb 24, 2017
10
1
3
43
Hi,

Proxmox is very "protective" when it comes to virtual disks. Depending on your storage, you cannot simply replace them with something else.
On some storage adapters there will be easier / faster ways, but this should work in any case:
  • Create a new VM and add a virtual disk to it that has the same (virtual) size as the disk you want to import.
  • In the hardware tab of your VM, note the name of the virtual disk file.
  • Open a CLI and use qemu-img's "convert" function to read the qcow2-file and export directly into the virtual disk. The exact parameters will depend on your storage and the target image format. If in doubt, read "man qemu-img" for details.
example: to import the image "source.qcow2" into the first virtual disk of VM 101 in a Ceph storage pool called "vmpool" in "raw" format, you would issue the following command:
qemu-img convert -O raw -p -n source.qcow2 rbd:vmpool/vm-101-disk-1
The parameter "-p" shows the progress, and "-n" tells qemu-img to write into an existing image instead of creating a new one.
 
  • Like
Reactions: niuk

niuk

New Member
Feb 20, 2017
27
0
1
55
Appreciate, meantime I added storage in Datacenter , named it 'images' and pointed to /mnt for disk images. Then for VM's (id 102) hard disk I pointed to that storage with qcow2 format. And finally copied my qcow2 image into default VM image of vm-102-disk-1.qcow2. It works just fine, I was able to complet emy setup and boot OS

root@pve:/mnt/images/102# ls -l
total 1946192
-rw-r--r-- 1 root root 1987444736 Mar 1 12:17 PA-VM-KVM-8.0.0.qcow2
-rw-r----- 1 root root 34365243392 Mar 1 12:07 vm-102-disk-1.qcow2
root@pve:/mnt/images/102# chmod o-r PA-VM-KVM-8.0.0.qcow2
root@pve:/mnt/images/102# ls -l
total 1946192
-rw-r----- 1 root root 1987444736 Mar 1 12:17 PA-VM-KVM-8.0.0.qcow2
-rw-r----- 1 root root 34365243392 Mar 1 12:07 vm-102-disk-1.qcow2
root@pve:/mnt/images/102# cp PA-VM-KVM-8.0.0.qcow2 vm-102-disk-1.qcow2
root@pve:/mnt/images/102# ls -l
total 3881736
-rw-r----- 1 root root 1987444736 Mar 1 12:17 PA-VM-KVM-8.0.0.qcow2
-rw-r----- 1 root root 1987444736 Mar 1 12:18 vm-102-disk-1.qcow2
 

udo

Well-Known Member
Apr 22, 2009
5,864
161
63
Ahrensburg; Germany
Hi,

Proxmox is very "protective" when it comes to virtual disks. Depending on your storage, you cannot simply replace them with something else.
...
Hi,
I think that's not right in all cases... if you have local storage on the normal filesystem (and enough space here - which is so in this case, because the qcow2-file is allready on this partition) you can simply overwrite an vm-disk with the right one.
Create an VM with an qcow2-disk on local storage and move the file like
Code:
mv /var/lib/vz/images/PA-VM-KVM-8.0.0.qcow2 /var/lib/vz/images/123/vm-123-disk-1.qcow2
start VM and if all right, you can move the vmdisk to another storage, if you want.

Udo
 
  • Like
Reactions: niuk

niuk

New Member
Feb 20, 2017
27
0
1
55
Now I created another VM , this time in local-lvm (pve) storage and neither can copy, move nor qemu-img convert ?

root@pve:/var/lib/vz/images# qemu-img convert -O raw -p -n PA-VM-KVM-8.0.0.qcow2 /dev/pve/vm-101-disk-1
qemu-img: output file is smaller than input file
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE 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 your own in 60 seconds.

Buy now!