Proxmox

In this tutorial, we will walk through the process of importing a virtual machine that has been stored as a QCOW2 file into a virtual machine that is present within the web-based Proxmox virtualization tool.

For those unfamiliar, QCOW stands for QEMU Copy-On-Write, and it is the default storage format for virtual disks used in QEMU/KVM instances, it is commonly used by applications like virt-manager or Quickemu.

Let’s break down the steps:

Step 1 - Creating a Directory for Storing QCOW2 Images: First, we need to establish a directory to house the QCOW2 images. You can choose a location of your preference, but in this example, we’ll create a directory named qcow under the default Proxmox storage directory.

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

Please note that you have the flexibility to save the images in a location of your choice. In the example we have made use of the ‘-p’ argument for mkdir to ensure that the entire directory up to including qcow is created in case any of them are not present on your system.

Step 2 - Copying the QCOW2 Images to the Proxmox Storage Directory: Download and copy the QCOW2 image to the directory created in the previous step. In this guide, we’ll use a Ubuntu 23.10 QCOW2 image as an example.

As you will most likely need to remotely connect to the server that is running Proxmox you will need to use the scp command. The location where the file will be stored on the remote server will need to be one that does not require administrative access.

$ scp Ubuntu\ 23.10.qcow2 {IP address of Proxmox server}:/home/alexberh 
$ sudo cp Ubuntu\ 23.10.qcow2 /var/lib/vz/template/qcow/ 

In the above example you will need to make sure to replace ‘alexberh’ with the username present on the Proxmox system.

You can verify if the image has been successfully copied by running:

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

Step 3 - Creating a VM Without an OS: Log in to the Proxmox Web UI dashboard, and navigate to your Proxmox node. Right-click and select the Create VM option from the context menu.

Enter the VM name and make a note of the VM ID. The ID is typically auto-generated based on the available VMs, but you have the option of entering a value of your choice. Click OK to proceed.

Choose Do not use any media since we already have an OS in the QCOW2 image. Select the guest type and version (e.g., Other) as appropriate.

Accessing Proxmox

Configure the graphics card, firmware, SCSI controller, virtual machine disk size (32 GB in this example), CPU details, memory size (2 GB in this example), and network settings (default settings usually work).

Review the VM settings and click Finish to create the VM. You can adjust the settings as needed by clicking Back.

Step 4 - Importing QCOW2 Image into Proxmox Server: Before importing the QCOW2 image into your Proxmox server, ensure you have the following details: VM ID, Proxmox storage name, and the location of the QCOW2 image file. Change to the directory where the QCOW2 image is located, for example:

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

Then, import the QCOW2 image into the Proxmox server using the following command, replacing the VM ID and storage name with your specific values:

$ sudo qm importdisk 120 Ubuntu\ 23.10.qcow2 

Step 5 - Attaching the QCOW2 Virtual Disk to the VM and removing the current Virtual Disk: In the Proxmox Web UI, select the virtual machine created in Step 3. Click Hardware. In the hardware section there should be a Hard Disk and Unused Disk items. Ensure that you are aware of the differences between the two items. Click on the Hard Disk item and then click on Detach, this will remove the virtual disk from the system and make it not viewable to the virtual machine. Click on the Unused Disk it might now appear as Unused Disk 0 and click on the Edit button. From here you can select VirtIO Block under Bus/Device before clicking on the Add button.

Please note selecting VirtIO Block as the bus type will ensure optimal disk I/O performance.

Step 6 - Changing the Boot Order: To boot from the newly added disk, adjust the boot order. Navigate to Virtual machine -> Options -> Boot Order, and ensure the new VirtIO disk is at the top of the boot order. If the new VirtIO disk is not in the top of the order you can drag it to the top.

Now, start the virtual machine, and it should boot from the new disk.

That concludes the process. You can now use your newly created virtual machine.