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

Create A KVM Virtual Machine Using Qcow2 Image In Linux

By sk

In this guide, we will see three ways to create a KVM virtual machine using Qcow2 image in Linux. For those wondering, QCOW, stands for QEMU copy-on-write, is the default storage format for virtual disks of QEMU/KVM instances. Some Linux distributions especially RHEL provides customized Qcow2 images, so we can instantly create and run new virtual machines with Red Hat Enterprise Linux OpenStack Platform, or KVM hypervisor.

Create A KVM Virtual Machine Using Qcow2 Image

We can import Qcow2 images in three different ways;

  1. using virt-install command,
  2. using Virt-manager gui application,
  3. using Cockpit web console.

1. Import Qcow2 images using virt-install command

virt-install is a command line tool to create KVM, Xen and Linux container guests. It is part of the Virt-manager package. If you haven't installed Virt-manager yet, refer the guide attached in "Virt-manager" section below.

To create new KVM VM using Qcow2 image, run:

$ virt-install --name CentOS_8_Server --memory 2048 --vcpus 1 --disk /home/sk/CentOS_8_Server.qcow2,bus=sata --import --os-variant centos8 --network default

Create a KVM virtual machine using Qcow2 image with virt-install

Replace "/home/sk/CentOS_8_Server.qcow2" with your actual path where you have saved the Qcow2 image.

This command will create a CentOS 8 KVM instance with 2GB RAM, 1 vCPU with Qcow2 virtual disk.

Once the VM is created, it will automatically open in Virt-viewer application. Virt-viewer is also part of the VIrt-manager package.

View running KVM instances with Virt-viewer utility

Start using the new VM!

To launch the same VM next time, run:

$ virsh --connect qemu:///system start centos8

Replace "centos8" with your VM's name.

You can view the list of available VMs using command:

$ virsh list --all

2. Import Qcow2 images using Virt-manager

Virt-manager is a graphical user interface application used for creating and managing virtual machines through libvirt. Refer the following guide to learn how to install and use Virtual-manager.

Once Virt-manager is installed, launch it from Dash or Menu.

Navigate to File -> New Virtual Machine. Virt-manager will have an "Import existing disk image" option in the first window when creating a new virtual machine. Choose it and click Forward button.

Import Qcow2 images using Virt-manager

Choose the actual path of Qcow2 image and then choose the operating system's variant you want to install. In my case, I chose CentOS 8.

Choose Qcow2 image location

Choose Memory and CPU settings for the new VM:

Choose Memory and CPU settings for the KVM instance

Check the "Customize configuration before install" option and click Finish.

Customize virtual machine configuration before installing it

Now you will see VM's configuration window. Click on "VirtIO Disk 1" setting from the left pane. On the right side pane, choose "SATA" as DISK BUS value under Advanced Settings. Click Apply to enable the changes.

Configure virtual disk settings for VM in Virt-manager

Next configure Network settings for the VM. To do so, click "NIC :xx:xx:xx" option and select the Network Source, Device model etc. Click Apply to save the changes.

Configure network settings for VM with Virt-manager

Finally, click "Begin Installation" on the top bar to start loading the new VM.

Create a KVM virtual machine using Qcow2 image with virt-manager application

You will be redirected to the Virtual machine's graphical console.

View running KVM instances with Virt-manager console

Start using the newly created VM!

3. Import Qcow2 images using Cockpit Web console

Cockpit is a web-based server administration tool for managing remote Linux machines via a web-browser.

Not just physical machines, we can also manage virtual machines via Cockpit. For more details, refer the following guide to learn how to manage KVM VMs via Cockpit:

Log in to your Cockpit web console. Then click on "Virtual Machines" tab on the left pane.

Click "Import VM" option to import the existing Qcow2 virtual disk image.

Import Qcow2 images using Cockpit Web console

Enter the Virtual machine name, choose the Qcow2 image file location, choose the memory size and click "Import" option. Make sure you've unchecked the box that says - "Immediately Start VM". Because, we need to do configure Disk and Network settings.

Create a KVM virtual machine using Qcow2 image via Cockpit web console

After importing the machine, you can adjust CPU, Memory and Network settings as per your requirement. First, we need to configure the Disk Bus Type.

To do so, Click on the "Disks" tab and click "Edit".

Configure virtual machine disk settings in Cockpit

Choose the bus type. The default is hypervisor dependent. For KVM, the default value is virtio. You need to select a valid bus type. I select the bus type as "sata" and click Save.

Select bus type for virtual disk in Cockpit

Next go to Network Interfaces tab, click "Edit", choose Interface Type and Source and finally click Save.

Configure network settings for virtual machine in Cockpit

Once everything is good, click "Run" to start the virtual machine:

Run KVM virtual machines from Cockpit

Go to the Consoles tab and see if the newly created VM is running!

View running KVM virtual machines in Cockpit

Hope this helps.

Thanks for stopping by!

Help us to help you:

Have a Good day!!

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. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More