How to Create KVM VM from Qcow2 with GUI or Command Line?

This post describes how to create KVM VM from qcow2 image with GUI (virt-manager) or command line to let you import data.

download-icon
Free Download
for VM, OS, DB, File, NAS, etc.
nick-zhao

Updated by Nick Zhao on 2023/02/10

Table of contents
  • Create KVM VM from qcow2 virtual disk in virt-manager

  • Create KVM VM from qcow2 image with virt-intall command line

  • Replace empty virtual disk with qcow2 image

  • Protect and manage VM with Vinchin Backup & Recovery

  • Sum Up

Server virtualization technology is adpoted by more and more companies so that IT administrators should learn the related knowledge to manage virtual environment later.

KVM is a popular open-souce hypervisor for virtual environment deployment. Compared with the closed-source hypervisor VMware ESXi, it costs less and ourperform VMware ESXi in some aspects.

VMware ESXi has provided web GUI like ESXi client and vCenter for vSphere virtual environment management while IT administrators will often manage KVM environment with command lines because it will be convenient to configure everything in the open-souce virtual environment. Of course, there are GUIs for KVM users like virt-manager to simply manage KVM virtual environment.

IT administrators need to know the virtual hard disk is important in VM management. In KVM environment, the virtual disk of VM is often saved as qcow2 format (QEMU copy-on-write 2). You can export the qcow2 image as backup because it contains the application data and it can be also used for VM migration.

After you get the qcow2 image, you can use it on every KVM host rather than the original host. If you convert qcow2 image to another format, like vmdk, you can use the virtual disk on another hypervisor.

Generally speaking, if you have the qcow2 image, you can directly create KVM VM with command or replace the empty virtual disk of a new KVM VM. In addition, you can also attach the qcow virtual disk to an existing VM but you have to configure the boot order later.

Create KVM VM from qcow2 virtual disk in virt-manager

Virt-manager is the virtual machine manager for KVM environment and provides the graphic interface to let users create virtual machine so you can easily create new VM with qcow2 image.

1. Open virt-manager > click the new virtual machine icon

2. The New VM wizard wille be open. Select Importing existing disk image > click Forward

3. Select qcow2 image path > select the operating system you want to install > click Forward

4. Select the memory and CPU for the new VM > click Forward

5. Type the name of the VM > click Finish

Find the new VM in virt-manager and then you can try booting it.

Create KVM VM from qcow2 image with virt-intall command line

Virt-install command will help you create new VM with qcow2 image in one step but you should make sure virt-manager has been installed on local machine before executing the command.

The command to create VM from exising qcow2 image is as below:

# virt-install

     --name demo

     --ram 512

     --disk image_directory.qcow2

     --import

You should replace the directory with the actual directory of the qcow2 image. There are actually many other options to let you configture the new VM and you can check them in the page of virt-install.

Replace empty virtual disk with qcow2 image

You can also create a new VM first and then substitue the empty virtual disk with the existing qcow2 image.

Get the directory of the virtual disk

# virsh domblklist guest

Replace it with the qcow2 image and then try booting the KVM VM.

Protect and manage VM with Vinchin Backup & Recovery

Disaster recovery is important in virtual environment. You can recover VM in a shorter time to reduce RTO.

Vinchin Backup & Recovery is a professional backup and disaster recovery solution for virtual environment like Red Hat Virtualization, oVirt, OpenStack, etc. (Native KVM is not supported for now) It will protect your virtual environment and simplify virtual environment management.

Vinchin Backup & Recovery

Vinchin Backup & Recovery supports agentless backup for KVM environment so you can quickly add your VMs to the backup system and there will be a user-friendly web console to help you easily start using this system.

Backup procedures are easy in Vinchin Backup & Recovery and you can select the backup strategies you want like automatic backup, schedule, incremental backup, differential backup, data compression, data encryption, etc. to easily protect VMs as you plan.

Vinchin Backup & Recovery allows you to recover VM to another host, not only the original host, but also VMware ESXi host and Xen Host. In other words, you can perform V2V migration in this system. In addition, Instant Recovery will let you quickly recover a failed VM with its backup in 15 seconds. Of course, you can use Instant Recovery and Cross-platform Migration at the same time.

Vinchin Backup & Recovery has beed selected by thousands of companies and you can also start to use this powerful system with a 60-day full-featured free trial. Just click the button to get the installation package.

Sum Up

If you have the qcow2 image, it can help you create new KVM virtual machine.

Virt-install command line can help you create new KVM VM from qcow2 image in one step and virt-manager can let you import qcow2 image to create new VM in GUI. If you have created a new VM, you can also replace the empty virtual disk with qcow2 image to create a new VM.

With Vinchin Backup & Recovery, you can protect virtual environment and easily recover VM from its backup. Don't miss the free trial.

Share on:

Categories: VM Tips
Free Trial Now close-icon