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
609 views

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

Introduction

Some OSes, firewall 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 in KVM hypervisor here.

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".

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.

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 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

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