How to create a new KVM virtual Machine on Debian 10 / Ubuntu 20.04?

Windows Articles

How To Configure Slave BIND DNS Server On Ubuntu 20.04

In our previous guide we covered the setup of Master(Primary) DNS Server. Here we'll learn that how to configure slave bind dns server on...

Install Fossil on Linux – An alternative to Git

Hello, friends. In this post, we will talk about a serious alternative to Git. In a few words, we'll show you how to install...

How to backup and restore BCD in Windows 10

Hi! Boot Configuration Data (BCD) is a set of data where the system boot information is stored. In addition, from there the operating systems...

How To Install and Configure Master BIND DNS Server On Ubuntu 20.04

Today we are going to learn that how to install and configure Master BIND DNS server on Ubuntu 20.04. As you all know that...

Diskpart is a very useful tool for managing storage in Windows 10.

Hello! Diskpart is an internal tool included in Windows systems that allows you to manage storage units. Indeed, it is possible to manage internal...
angeloma
angeloma
Senior Writer and partner

In the previous post, we explained How to install KVM on Debian 10 / Ubuntu 20.04. Now it’s time to create a KVM Virtual Machine.

Creating a new KVM Virtual Machine on Debian 10 / Ubuntu 20.04

Creating a network bridge

Before creating a virtual machine, the following must be taken into account. A new network interface is created when installing KVMs. If you are going to test some systems this is enough, but if you want the virtual machine to be accessible from the whole network then you have to create a Bridge.

To do this, edit the interfaces file:

:~$ sudo nano /etc/network/interfaces

And add the following:

auto ens33
iface ens33 inet manual

auto br0
iface br0 inet static
address x.x.x.x
netmask x.x.x.x
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x
bridge_ports ens33
bridge_stp off
bridge_fd 0
bridge_maxwait 0
dns-nameservers x.x.x.x

In my case, the physical network interface is ens33. Remember you can find out your network interface by typing:

:~$ ip addr

And the network parameters depend on each case. And you have to replace them with your own.

Save the changes, exit the editor, and reboot your computer.

In case you are doing this tutorial on a Debian 10 / Ubuntu 20.04 system that has a desktop environment installed, you can do it through the Network options. There the process is more intuitive and easier to do on GNOME, KDE, or Cinnamon.

Remember that this step is optional.

Creating the KVM Virtual Machine using Virt-Manager

Virt-Manager is a program that allows us from a graphic interface to create a KVM Virtual Machine. If you are using Debian with a desktop environment then this section of the tutorial is for you.

So, install it with the following command

:~$ sudo apt install virt-manager
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
gir1.2-gtk-vnc-2.0 gir1.2-libvirt-glib-1.0 gir1.2-spiceclientglib-2.0
gir1.2-spiceclientgtk-3.0 python-asn1crypto python-certifi
python-cffi-backend python-chardet python-cryptography python-enum34
python-idna python-ipaddress python-openssl python-requests python-urllib3
Suggested packages:
python-cryptography-doc python-cryptography-vectors python-enum34-doc
python-openssl-doc python-openssl-dbg python-socks python-ntlm
python3-guestfs
The following NEW packages will be installed:
gir1.2-gtk-vnc-2.0 gir1.2-libvirt-glib-1.0 gir1.2-spiceclientglib-2.0
gir1.2-spiceclientgtk-3.0 python-asn1crypto python-certifi
python-cffi-backend python-chardet python-cryptography python-enum34
python-idna python-ipaddress python-openssl python-requests python-urllib3
virt-manager
0 upgraded, 16 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,400 kB of archives.
After this operation, 12.1 MB of additional disk space will be used.
Do you want to continue? [Y/n]
1.- Installing Virt-manager on Debian 10 / Ubuntu 20.04
1.- Installing Virt-manager on Debian 10 / Ubuntu 20.04

It will then be available from the main menu. When you start it, you will be asked for the root password.

And you will see the main screen:

2.- Virt-manager main screen
2.- Virt-manager main screen

Press the button to create a new virtual machine.

Then, select how you want to get the image of the virtual machine. It can be local or remote. In my case, I will choose local because I already downloaded it.

3.- Creating a new KVM Virtual Machine
3.- Creating a new KVM Virtual Machine

Clicking the Browser button and then the Browse Local button you can choose the system image from your computer.

4.- Select the OS image
4.- Select the OS image

Then set how much RAM and CPU memory the new virtual machine will use.

5.- KVM Virtual Machine settings
5.- KVM Virtual Machine settings

On the next screen, set the storage disk of the virtual machine. In this section you can set the size or disable the storage. Useful for LIVE images of distributions.

6.- Disks options
6.- Disks options

Then you will see the virtual machine summary and on this screen, you can choose the network to use.

7.- Creating a new KVM virtual machine on Debian 10 / Ubuntu 20.04
7.- Creating a new KVM virtual machine on Debian 10 / Ubuntu 20.04

And that’s it, the virtual machine will start.

8.- A KVM Virtual Machine running
8.- A KVM Virtual Machine running

Creating the KVM Virtual Machine from the terminal

Sure, the above step works if there is a desktop environment installed, but what if not? Well, you can also create it using the terminal.

To do this, you should create a folder where the files of this virtual machine will be. Inside this folder, you can create two more, one for the image and another for the storage.

:~$ mkdir -p virtual/{iso,storage}

In that ISO folder should be the image of the operating system you want to install in the virtual machine. Remember that using the wget command you can get one.

And now the command that creates the virtual machine is this:

:~$ sudo virt-install --name [name] --os-type linux --os-variant [linux-distribution] --ram [size] --vcpu [number] --disk path=[path]/[name].qcow2,size=10 --graphics vnc,listen=0.0.0.0 --noautoconsole --hvm --cdrom [path] --boot cdrom,hd

Remember to change the values in [] to the ones that are right for you.

If there is no error in the screen output, it means that the machine has been successfully created.

To access it, use a VNC client and use your IP address and port 0.

Conclusion

KVM is a wonderful technology that allows you to create virtual machines quickly. Whether using a graphical interface or the terminal the result is the same.

So, share this post and join our Telegram Channel.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How To Configure Slave BIND DNS Server On Ubuntu 20.04

In our previous guide we covered the setup of Master(Primary) DNS Server. Here we'll learn that how to configure slave bind dns server on...

Install Fossil on Linux – An alternative to Git

Hello, friends. In this post, we will talk about a serious alternative to Git. In a few words, we'll show you how to install...

How to backup and restore BCD in Windows 10

Hi! Boot Configuration Data (BCD) is a set of data where the system boot information is stored. In addition, from there the operating systems...

How To Install and Configure Master BIND DNS Server On Ubuntu 20.04

Today we are going to learn that how to install and configure Master BIND DNS server on Ubuntu 20.04. As you all know that...

Diskpart is a very useful tool for managing storage in Windows 10.

Hello! Diskpart is an internal tool included in Windows systems that allows you to manage storage units. Indeed, it is possible to manage internal...
x