Arch

How To Install KVM on Arch Linux

How To install KVM on Arch Linux

Creating virtual machines allows users to run multiple operating systems on a single system and to make it possible there are various virtualization software available. One of the technologies used for virtualization is KVM, known for its high performance, better security, and stability. The Kernel-based Virtual Machine technology is primarily based on the Linux kernel which means it is compatible with all the Linux distributions. On Arch Linux, the installation of KVM is quite simple which is explained in the guide.

Outline:

How To Install KVM on Arch Linux

KVM is an open-source virtualization software that requires a Linux kernel on the host system having virtualization features turned on and that doesn’t mean that it is only supported on Linux-based systems. Moreover, KVM acts as Hypervisor type 1 running on bare metal. To install KVM on Arch the first thing that you need to do is to see if the virtualization is enabled on your system or not and for that execute:

grep -Ec '(vmx|svm)' /proc/cpuinfo

Upon the execution of the above command, you can expect two types of output. If there is a zero on the output then it means that virtualization is inactive and if it is any non-zero number then it means the virtualization feature is active:

Normally virtualization is by default active but in some cases, it might be inactive so to activate it you have to go to your host system BIOS. Next, install the KVM and execute the below command which installs various packages which are necessary to create and manage a virtual machine using KVM:

sudo pacman -S qemu-full virt-manager virt-viewer dnsmasq bridge-utils libguestfs ebtables vde2 openbsd-netcat

Here is a brief detail about the packages installed in the above command:

Qemu-full: It is an emulator that serves the purpose of running various operating systems as guests on KVM and supports both hardware virtualization and software virtualization.

 

Virt-manager: This is a graphical user interface for managing the virtual machine and through it, virtual machines can be created, modified, and monitored using the libvirt library.

Virt-viewer: To interact with the graphical display of a virtual machine, this viewer is installed. It supports VNC, RDP, and SPICE protocols, its installation is required to access the graphical console of the virtual machine.

Dnsmasq: This is a lightweight DHCP and DNS server that is used to provide network services for virtual machines. Further, it is needed to configure network settings and enable the internet service for the virtual machine.

Bridge-utils: To create and manage network bridges that are connected with one or more network segments this bridge utility needs to be installed. The bridge interface is used by the virtual machines to communicate either with each other or with the host.

Libguestfs: To create and modify the disk images for the virtual machine, this tool is installed on Arch, and it supports various formats like qcow2, raw, vmdk and vdi. Furthermore, it can be used for resizing partitions and cloning image files.

Ebtables: On the Linux bridge, the filtration and monitoring of Ethernet frames is required which can be used for implementing firewall rules, NAT, or any other network functions. Further, it can be used to control traffic between the host and virtual machines.

Vde2: To perform functions like encryption, multicast, and VLAN this virtual distributed Ethernet system can be installed. It can create virtual switches and cables to connect with virtual machines.

Openbsd-netcat: To create TCP and UDP connections or to transfer data this network utility is installed. It can also be for testing, tunneling, and debugging purposes.

Note: KVM and QEMU are two different virtualization technologies, one has a type 1 hypervisor and the other has a type 2 hypervisor. KVM runs directly on hardware, whereas QEMU runs on top of the operating system. QEMU uses KVM as a backend to access hardware resources and use the software emulation to visualize the hardware.

To manage the virtualization platform libvirt service on Arch should be activated and enabled, so for that, you need to create a group named lubvirt and give it permissions. To do that, simply open the configuration file for libvurtd on Arch using any editor and uncomment the following code lines:

unix_sock_group = "libvirt"

unix_sock_rw_perms = "0777"

After that, add the current user to the group created by uncommenting the code lines above, this is required for managing virtual machines using this library:

sudo usermod -aG libvirt $USER

Now first enable the libvirtd service:

systemctl enable libvirtd.service

Next start the service:

systemctl start libvirtd.service

Now verify the status of the libvirtd service:

systemctl status libvirtd.service

Now you can launch the KVM on Arch Linux from the applications menu by searching it:

How to Turn on Virtualization For Arch Linux on Virtualbox

If you are trying to do nested virtualization then there are chances that virtualization would not be enabled as default. So for that, navigate to the installed directory of VirtualBox on the Windows operating system and search for the VBoxManage execution file. If it is present, then copy the address:

Now launch the PowerShell and go to the copied directory:

cd "<path-to-virtualbox-directory>"

Next, first list the virtual machines linked with VirtualBox to get the confirmation on their names and then enable the virtualization for Arch Linux:

.\VBoxManage modifyvm "<virtual-machine-name> " --nested-hw-virt on

Now you can verify enabling Nested VT-x/AMD-V feature by going to Arch Linux settings processor settings:

How To Create a KVM on Arch Linux

To create a virtual machine on Arch Linux there are a number of different software available like VMware and VirtualBox. To use KVM for this purpose, launch it in Arch from the applications menu:

Now click on the computer icon on the top left side and then select the method for installation along with the system architecture and then click on Forward:

Here I have selected the method of installing Ubuntu with its ISO file, so I have to load the setup file by linking the download directory by clicking on Browse Local option:

Once you have linked the directory, select the file ISO file in the directory and afterward click on Choose Volume:

Next set the appropriate RAM and CPUs for the virtual machine and then click on Forward:

Next, for storage of the virtual machine you can either create a separate disk or you can just allocate a specific amount of space for the virtual machine. Here I have created a separate disk for my Ubuntu, for that I have selected the manage option:

Now here you can either link any other directory or simply select the already linked directory and create a disk by clicking on the Create sign. Next, add its name, select its format, allocate the space, and click on Finish:

Now verify the details and if you need to play with more settings then check the box for Customize configuration before install option and then click on Finish:

Next, a range of different options will appear on the tab here you can set the options according to your preference and can also add or remove them either by selecting Add hardware or Remove hardware:

Once you are all set, just proceed with installation by clicking on Begin Installation. Once the installation is complete, the virtual machine will appear on KVM:

Note: This setup will work fine if you have the host system is not virtual, but if the host system is also virtual it means that you are trying to create nested virtualization, then you might experience difficulties while installing any operating system using KVM.

Conclusion

KVM refers to a kernel-based virtual machine that is open source and turns Linux into a hypervisor type 1 bare metal which requires system-level components and KVM provides these virtually. To install KVM you need to install the QEMU full package along with virtual manager for GUI support. Moreover, to successfully create a virtual machine, you need to enable the virtualization first and then activate the libvirtd service.

Similar Posts