Home Proxmox How To Import QCOW2 Image Into Proxmox

How To Import QCOW2 Image Into Proxmox

Attach A QCOW2 Virtual Disk To Proxmox VM

By sk
Published: Updated: 192.5K views

In this guide, we will see how to import QCOW2 into Proxmox VE hypervisor and how to create a virtual machine using the QCOW2 image in Proxmox.

Introduction

Some OSes, and firewalls or network appliances are shipped only in QCOW2 format.

For those wondering, QCOW, stands for QEMU copy-on-write, is the default storage format for virtual disks of QEMU/KVM instances.

Using the QCOW2 images, we can instantly create and run new virtual machines with hypervisor. We already have documented the steps to import QCOW2 images into KVM hypervisor in the following link:

How To Create A KVM Virtual Machine Using Qcow2 Image In Linux

Step 1: Create a Directory to Store QCOW2 Images

First, we need to create a directory to store the QCOW2 images. I am going to create a directory called "qcow" under the Proxmox default storage directory.

$ sudo mkdir /var/lib/vz/template/qcow

Please note that you can save the images on any location of your choice.

Step 2: Copy the QCOW2 Images to Proxmox Storage Directory

Download and copy the QCOW2 image to the directory that you created earlier. For the purpose of this guide, I will be using FreeBSD 12.3 QCOW2 image file.

$ sudo cp Software/FreeBSD\ 12\ Qcow2/FreeBSD-12.3-RELEASE-amd64.qcow2 /var/lib/vz/template/qcow/

You can verify if the image is really copied or not.

$ ls -l -h /var/lib/vz/template/qcow/

Sample Output:

total 3.2G
-rw-r--r-- 1 root root 3.2G Jun 13 16:17 FreeBSD-12.3-RELEASE-amd64.qcow2
Copy QCOW2 Image To Proxmox Storage
Copy QCOW2 Image To Proxmox Storage

Step 3: Create a VM Without OS

Log in to the Proxmox Web UI dashboard by navigating to https://ip-address:8006 URL.

Right click on your Proxmox node and click "Create VM" option from the context menu.

Create New VM In Proxmox
Create New VM In Proxmox

Enter the name of the VM. Also make a note of the VM ID (i.e. 107 in my case). The ID will be auto-created based on the existing number of available VMs. We are going to need the VM ID when we attach the QCOW2 image to the VM. Click OK to continue.

Enter VM Details
Enter VM Details

Next choose "Do not use any media" option. Because we already have a pre-installed OS in the QCOW2 image, right? Yes! Also choose the guest type and version. There is no entry for Unix guest OS in Proxmox, so I simply selected "Other". If you use import a Linux Qcow2 image, choose guest type as "Linux" and Kernel as "6.x-2.6 Kernel".

Choose 'Do Not Use Any Media' Option
Choose 'Do Not Use Any Media' Option

Choose the graphics card, firmware and SCSI controller settings for your VM. usually, the default values are sufficient. I will go with default values.

Enter System Details For VM
Enter System Details For VM

Enter the size for the virtual machine's disk. Here, I will keep the default size i.e. 32 GB. Also make sure you've chosen the disk format as "QEMU image format" as shown in the following screenshot.

Enter Disk Size For VM
Enter Disk Size For VM

Enter the CPU details such as number of sockets and cores.

Enter CPU Details
Enter CPU Details

Enter the RAM size for your VM. here, I have given 2 GB.

Enter Memory Details
Enter Memory Details

Enter network details. Mostly the default settings will work just fine. If you wish to change the network settings (E.g. enable or disable firewall), do it as you wish.

Enter Network Details
Enter Network Details

You will see the summary of the VM's settings. Review them and if you're OK with it, click Finish to create the VM. Or click "Back" button and change the settings as you wish.

Confirm VM Creation
Confirm VM Creation

We just created a VM without OS. It is time to attach the QCOW2 image to the VM.

Step 4: Import QCOW2 Image into Proxmox Server

Before importing the QCOW2 into your Proxmox server, make sure you've the following details in hand.

  1. Virtual machine's ID,
  2. Proxmox storage name,
  3. Location of the Proxmox QCOW2 image file.

If you don't have them or don't know where to find them, just open your Proxmox web UI dashboard. On the left pane, you will see the virtual machine's IDs and the storage name.

Virtual Machine IDs And Storage Name In Proxmox
Virtual Machine IDs And Storage Name In Proxmox

Here, my FreeBSD 12 VM id is "107" and Proxmox storage name is "local". And the directory path where I saved the QCOW2 image is /var/lib/vz/template/qcow/ (Please refer Step 2.).

Change into the /var/lib/vz/template/qcow/ directory:

$ cd /var/lib/vz/template/qcow/

Now, import the QCOW2 image into the Proxmox server using command:

$ sudo qm importdisk 107 FreeBSD-12.3-RELEASE-amd64.qcow2 local

Replace the VM id (107) and storage name (local) with your own.

Sample Output:

importing disk 'FreeBSD-12.3-RELEASE-amd64.qcow2' to VM 107 ...
Formatting '/var/lib/vz/images/107/vm-107-disk-1.raw', fmt=raw size=5369626624 preallocation=off
transferred 0.0 B of 5.0 GiB (0.00%)
transferred 52.7 MiB of 5.0 GiB (1.03%)
[...]
transferred 5.0 GiB of 5.0 GiB (100.00%)
transferred 5.0 GiB of 5.0 GiB (100.00%)
Successfully imported disk as 'unused0:local:107/vm-107-disk-1.raw'
Import QCOW2 Into Proxmox
Import QCOW2 Into Proxmox

We imported the virtual disk to Proxmox. Now go back to the Proxmox web UI dashboard and attach the virtual disk to the VM.

Step 5: Attach QCOW2 Virtual Disk to VM

Click on the Virtual machine that you created in step 3. In my case, it is FreeBSD 12 VM. Select "Hardware" tab. On the right hand side, you will the newly imported QCOW2 disk as unused disk. Select the unused disk and then click "Edit" button.

Edit Unused Disk
Edit Unused Disk

Choose the bus type as "VirtIO Block" to get best disk I/O performance and hit "Add" button.

Change Bus Type To VirtIO Block
Change Bus Type To VirtIO Block

You will now see a newly disk with VirtIO as bus type has been attached to the VM.

Attach New Disk To Proxmox VM
Attach New Disk To Proxmox VM

Great! We successfully attached a new disk to the Proxmox VM.

Step 6: Change the Boot Order

To make the VM to boot from the newly added disk, we must change the boot order.

Select Virtual machine -> Options -> Boot Order.

Select Boot Order
Select Boot Order

In order to boot from the new disk, it must be on top in the boot order window. Select the newly added VirtIO disk and drag it to the top. Make sure you checked the tick box to enable the disk. Click "OK" to save.

Change Disk Boot Order In Proxmox
Change Disk Boot Order In Proxmox

Now start the virtual machine. It should boot from the new disk.

FreeBSD Virtual Machine Running In Proxmox
FreeBSD Virtual Machine Running In Proxmox

That's it. Start using the newly created virtual machine.

Conclusion

This guide explained how to import a QCOW2 disk image into Proxmox VE and how to create a new virtual machine using the QCOW2 virtual disk. By following this guide, you can import any software appliances that are available in QCOW2 format in Proxmox hypervisor.

You May Also Like

22 comments

Christophe July 26, 2022 - 1:32 am

Hello,
I followed your tutorial to import the VM offered on the HomeAssistant site. My only modification: the bios which must be in UEFI for the VM starts.
Great job, thanks !!!

Reply
sk July 26, 2022 - 10:57 am

Thanks for the tip. This will help someone.

Reply
Jeremy February 16, 2023 - 7:33 am

Just to add, for HomeAssistant OS (where you download the full VM image), it is also necessary to add an EFI disk to the VM config. Then UEFI boot will work.

Reply
Vlad October 15, 2022 - 5:57 pm

I had to turn off Secure Boot.

Reply
Treadmill November 7, 2022 - 2:18 am

This article is no longer correct.
QEMU disk types are no longer supported by proxmox by default (the option is greyed out). I have no idea what the correct procedure is now.

Reply
sk November 7, 2022 - 11:30 am

This is STILL CORRECT and WORKING procedure. I just tested with a new FreeBSD QCOW2 image. It WORKS well.

Reply
Jordan August 14, 2023 - 3:23 am

Still works, but read the help of Proxmox:
“Storages which present block devices (LVM, ZFS, Ceph) will require the raw disk image format, whereas files based storages (Ext4, NFS, CIFS, GlusterFS) will let you to choose either the raw disk image format or the QEMU image format.”
And you will find the answer

Reply
vik November 22, 2022 - 10:16 pm

Hi,
I did as it is written in the procedure. But I have this kind of problem: “booting from hard disk …”

Reply
sk November 23, 2022 - 12:28 pm

Please elaborate. Post the complete error message.

Reply
Vik November 23, 2022 - 1:39 pm

Error message:
“SeaBios (version rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org)
Machine UUID 027870eb-e60b-4eaa-b9f7-67becbf7954d
Booting from Hard disk..”
It stays like this and doesn’t charge anything

Reply
sk November 23, 2022 - 3:38 pm

Hmm… never encountered this error before. As far as I understood, you are booting a GPT disk with the default old-style BIOS. It may not work. Please try to change the machine ID to “q35” and Bios to “UEFI” and try. It might work. Please check the following links.
https://serverfault.com/questions/1092408/qemu-kvm-hangs-booting-from-hard-disk
https://serverfault.com/questions/899290/kvm-gets-stuck-at-booting-from-hard-disk

Reply
Alex June 10, 2023 - 11:30 am

This worked for me when cloning a Windows 10 machine from VMWare Workstation player

sk June 10, 2023 - 2:28 pm

Glad it worked for you.

torstenzenk February 8, 2023 - 10:21 pm

Hi SK,
thanks for this great Step-by-Step Tutorial. It is working great, but at on step could you add this information:
STEP 5 where it says: Choose the bus type as “VirtIO Block” to get best disk I/O performance.Could you please add: AND HIT THE “ADD” BUTTON.

As all of the necessary step before and after are surrounded by red squares (which is great!) this red square at the ADD-Button is missing in the screenshot there, so i missed it and wondered why my new disk wasn’t added. 🙂
Thanks a lot!

Reply
sk February 9, 2023 - 12:28 pm

I just added the note. Hope everything is clear now.

Reply
jan labitad March 27, 2023 - 7:34 am

Hello SK,

i have the qcow2 file on my local machine and i was wondering how do you copy it to the virtual machine. do i use the directory of the qcow2 file on my local machine as the origin of the file?

Reply
sk March 27, 2023 - 11:58 am

You can copy Qcow2 file from your host system to guest system using scp command. https://ostechnix.com/securely-transfer-files-with-scp-in-linux/

Reply
louis June 7, 2023 - 12:12 am

cd /var/lib/vz/template/qcow/sbc/
qm disk import 103 sbc-F7.40A.250.265.qcow2 local-lvm -format qcow2

worked for me

Reply
Ben K August 29, 2023 - 8:36 pm

I finally got it to work (Proxmox 8 on x86_64) after reading all of the comments and doing some googling. It worked after:

-Adding EFI disk to the VM to be able to use UEFI.
-Switching BIOS from SeaBIOS to OMVF (UEFI)
-Catch the VM during boot, hit escape to edit boot options, and turn off “try secure boot” in the sub-menus

Reply
sk August 30, 2023 - 11:48 am

Thank you very much for sharing your tips, Ben K. Hope this solution will help someone. Much appreciated.

Reply
Rene May 1, 2024 - 6:22 pm

Hi SK, thanks for the manual! Now running ProxMox 8.2.2 and I also encountered the Uefi setting but figured that one out fast enough. Some screens where a bit different, the only thing that I would suggest was a change in the import: qm importdisk 107 FreeBSD-12.3-RELEASE-amd64.qcow2 local <- local did not work for me, but local-lvm did.

Reply
sk May 1, 2024 - 6:26 pm

“local did not work for me, but local-lvm did”

It is because, the storage name is “local-lvm” for your setup. In my case, I have given “local” as my storage name. Anyway. I am glad that the guide helped. I will soon update this guide with Proxmox version 8.2. Thanks for the comment.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More