Create VM from existing qcow2 image ?

niuk

New Member
Feb 20, 2017
27
0
1
60
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
 
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
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
 
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: NiKTaMeR and niuk
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
 
Only since I reached the same point:

You have to look with
qemu-img info xxx.qcow2
for the 'virtual size' of the disk. This size needs to be created as vm-disk.
Then it fits.:)
 
You do not have to think about disk sizes anymore today. Use qm importdisk instead.

For example, if you want to import a single file from /home/root/someimage.raw
You first create a new VM in the GUI and immediately remove its disk again.
Assume it got the ID 130.
Let's say you want to save the VM disks on the default storage local-lvm.
You got to CLI and enter
Code:
qm importdisk 130 /home/root/someimage.raw local-lvm
Done.

Soon, this will be possible in the GUI without any CLI interaction.
 
hello , the qm importdisk was good and fast but could not boot the Vm got many error like
you might want to regenerate your initramfs ... any help how to fix
 
You might have to switch BIOS/UEFI or try between IDE, SATA, SCSI for the disk.
 

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!