Virtualization is one of the most widely used technologies in both corporate and home environments. Whether you’re an experienced IT professional, programmer, or new to IT, virtualization can be one of your best friends.
Virtualization is the abstraction of a computer’s hardware resources with a software application known as a hypervisor. The hypervisor creates an abstraction layer over the computer hardware and virtualizes various system components, including but not limited to memory, processor, storage, USB devices, etc.
In doing so, it allows you to create virtual computers, also known as virtual machines, from virtualized elements, and each virtual machine, also known as a guest, runs independently of the host system.
KVM, short for Kernel-Based Virtual Machine, is an open source type 1 hypervisor (bare metal hypervisor) integrated into the Linux kernel. It allows you to create and manage virtual machines running Windows, Linux, or UNIX variants such as FreeBSD and OpenBSD.
As mentioned earlier, each virtual machine has its own virtual resources such as storage, memory, CPU, network interfaces, USB interfaces, and video graphics, just to name a few.
QEMU (Quick Emulator) is a software module that emulates various components of computer hardware. It supports full virtualization and works alongside KVM to provide a holistic virtualization experience.
Step 1Check if virtualization is enabled in Ubuntu
First, check if your processor supports virtualization technology. Your system must have either an Intel VT-x (vmx) processor or an AMD-V (svm) processor.
To verify this, run the following egrep command.
$ egrep -c '(vmx|svm)' /proc/cpuinfo
If virtualization is supported, the output must be greater than 0, such as 2,4,6, etc.
Alternatively, you can run the following grep command to display the type of processor your system supports. In our case, we are using Intel VT-x, denoted by the vmx parameter.
$ grep -E --color '(vmx|svm)' /proc/cpuinfo
It is equally important to check if KVM virtualization is supported by running the following command:
If the kvm-ok utility is missing, install the cpu-checker package as follows.
$ sudo apt install cpu-checker -y
Now that we have verified that our system supports KVM virtualization, let’s go ahead and install QEMU.
Step 2. Install QEMU/KVM on Ubuntu 20.04/22.04.
Then update the package lists and repositories as follows.
$ sudo apt update
After that, install QEMU/KVM along with other virtualization packages as follows:
$ sudo apt install qemu-kvm virt-manager virtinst libvirt-clients bridge-utils libvirt-daemon-system -y
Let’s take a look at what role each of these packages plays.
- qemu-kvm is an open source emulator that emulates the hardware resources of a computer.
- virt-manager is a Qt-based GUI for creating and managing virtual machines using the libvirt daemon.
- boil is a set of command line utilities for creating and modifying virtual machines.
- libvirt-clients – API and client libraries for managing virtual machines from the command line.
- bridge-utils – a set of command line tools for managing bridge devices.
- libvirt-daemon-system – Provides the configuration files needed to run the virtualization service.
At the moment, we have installed QEMU and all the necessary virtualization packages. The next step is to start and enable the libvirtd virtualization daemon.
So run the following commands:
$ sudo systemctl enable --now libvirtd $ sudo systemctl start libvirtd
Then check if the virtualization service is running as shown.
$ sudo systemctl status libvirtd
Based on the output above, the libvirtd daemon is up and running as expected. Also, add the logged in user to the kvm and libvirt groups as shown below.
$ sudo usermod -aG kvm $USER $ sudo usermod -aG libvirt $USER
Step 3: Launch Ubuntu Virtual Machine Manager
The next step is to launch the QEMU/KVM graphical tool, which is a virtual machine manager.
$ sudo virt-manager
The Virtual Machine Manager will appear as shown in the figure. From here, you can start creating and managing virtual machines, as we’ll demonstrate shortly.
Step 4: Create a virtual machine with QEMU/KVM on Ubuntu
In this section, we’ll show you how to create a virtual machine using an ISO image. For demonstration purposes, we will use the Fedora Live ISO image. You can use the ISO image of your preferred OS and follow the instructions.
To get started, click the icon in the top left corner as shown below.
Since we are creating a virtual machine from an ISO file, select the first option – “Local installation media (ISO image or CD)”. Then click “Forward”.
Then click “Browse” to navigate to the location of the ISO file.
Since the ISO file is saved locally on your system, we will click “Browse Locally”.
Be sure to navigate to the location of your ISO file. Click on it and then click “Open”.
Before proceeding, make sure you have selected your operating system from the drop-down menu. Then click “Forward”.
Click “Yes” on the pop-up window to give the emulator permissions to search for the ISO file.
Then select the memory size and number of CPU cores and click Next.
In the next step, enable storage for the virtual machine and specify the size of the virtual disk. Then click “Forward”.
Finally, check all the settings you have defined and if everything looks good, click Finish to create the virtual machine. Otherwise, click “Back” and make the necessary changes.
As soon as you click Finish, the Virtual Machine Manager will start creating a virtual machine based on the configurations you have provided.
And after a few seconds, the virtual machine installation wizard will appear. You can proceed with the installation in the same way as you would on a physical system.
Also, your VM will be listed in the Virtual Machine Manager as shown below. By right-clicking on your virtual machine, you can perform various tasks including suspending, rebooting, resetting, and deleting the virtual machine among many others.
#install #configure #QEMUKVM #Ubuntu
❤ XOXO ❤