How to Install, Configure, and Create a Virtual Machine on Ubuntu

KVM Kernel-based virtual machine is a virtualization application developed for the Linux kernel that converts it to a higher system.

Before installation, login to our server to see if it supports CPU, let’s check the CPU information with the help of the following commands.

The output of this command means  “CPU(s):0 does not support if it is 0, and if it is more than 1 or 1, it means it supports.


You can also use the command below to check whether the kernel modules are installed.

Then reboot the server.

You can also use the brctl show command to display the subsequent virtual interface (NIC).

Default is the directory where Virtual Machines (qcow2) are stored.

Note1: If you do not know the location of the disk in the qcow2 format, the following command (the command lists the corresponding VM disks with the directory where it is located) will tell you where it is.

Default is the directory where the installation iso is stored for Virtual Machine images.

Default is where Virtual Machine features (ram, cpu, disk, etc.) are stored in xml format.

Note2: The following command prints the features (ram, cpu, disk, etc.) where the machine is kept in xml format.

You can view the existing virtual machines with the following two commands.


You can use virt interface to manage, create and delete Virtual Machines as GUI. The command is as follows.

Note 3: To do this, you must first connect to the server using the -X parameter (ssh -X root@ You also need to have the Xming application for Windows (Putty must be enabled on x11) and the Xquartz application for Mac to be installed and running.

Note4: In the meantime, I have to give you another information. If you are a Linux user, that is, if your client machine is Linux, you can connect to the server and install File-Add Connection if you have a  virt-manager on your client machine.

Virtual Machine Manager
Virtual Machine Manager

Or you can get the console of the server directly with the command below.

Note 5: To do this, you must first install the virt-viewer package on the user machine (ubuntu/debian for ’apt install virt-viewer’, Redhat/CentOS for ‘yum install virt-viewer’).

Ubuntu18-Virt Viewer
Ubuntu18-Virt Viewer

I will share a few commands below to manage the server through the commands.

Starts the server.

Turns off the server.

Restarts the server.

Used to change the properties of the server (changes the xml file).

When the host hosting the presentation is turned on, this is the option to automatically start vm as well.

When the host hosting the presentation is turned on, this vm also disables the auto-start option.

Now let’s look at the virt-install command, which you can use to create a machine from the command line. You can use this example with the command below. I have used a lot of parameters but you don’t have to use all the parameters. Default values will be assigned instead of parameters you have not already used. You can then change these values. After executing the command, GUI will open and direct you to the installation.

Ubuntu-cli-Virt Viewer
Ubuntu-CLI-Virt Viewer

Now let’s talk about “virt-clone” command. As the name suggests, it is the command used to get a clone. Its use is as follows. But you can get clone when VM is off, otherwise, it will give warning. You should get “Clone ‘Ubuntu18.clone’ created successfully.” Warning.

The command below converts a vmdk in vmdk to qcow2 and runs it on your KVM host.

In our next article, we will look at how to make backups in the KVM environment and then restore and restore the backup we have made.

I hope it has been a useful article.