How to Install KVM in Arch Linux and Configure Virtual Machine
Want to run different operating systems on your Arch Linux installation? You can always use VirtualBox or VMware to create virtual machines, but KVM has the upper hand with its high performance and flexible feature set.
At first, setting up a new virtual machine on Arch Linux using KVM and QEMU can seem daunting. But fret not, as it will be very easy to learn how to do it.
Here's everything you need to know about installing KVM in Arch Linux and configuring your first virtual machine.
Step 1: Check if virtualization is enabled
The first step is to verify that you have enabled virtualization support on your computer. To do so, run the following command:
grep -Ec '(vmx|svm)' /proc/cpuinfo
Note the output. If it is greater than 0, then virtualization is enabled and you can safely continue. But in case this has not been done, you need to enable virtualization by accessing the BIOS of your computer.
Step 2: Install the necessary KVM packages
Now that you are sure about virtualization support, it's time to install the necessary packages for KVM. But first, update the existing packages on your system using:
sudo pacman -Syyu
Then run the following command to install all KVM related packages:
sudo pacman -S qemu-full virt-manager virt-viewer dnsmasq bridge-utils libguestfs ebtables vde2 openbsd-netcat
Enter Y when prompted for confirmation.
Step 3: Configure the libvirtd . service
Start the libvirtd service with:
sudo systemctl start libvirtd.service
Enable the service so that it automatically starts at boot:
sudo systemctl enable libvirtd.service
Check if libvirtd is currently running with the status command :
sudo systemctl status libvirtd.service
The output will show active (running) status in green. If it shows inactive (dead) , execute the systemctl start command again.
Next, you need to make some changes to the libvirtd configuration file located at /etc/libvirt/libvirtd.conf. Open the file with Vim (or your favorite text editor):
vim /etc/libvirt/libvirtd.conf
Locate and uncomment the following two lines by removing the # character from the beginning:
unix_sock_group = "libvirt" unix_sock_rw_perms = "0770"
Save changes and exit Vim to continue. Next, add your user to the libvirt group with:
sudo usermod -aG libvirt $USER
Restart the libvirtd service to save the changes:
systemctl restart libvirtd.service
You are now ready to create a KVM on your Arch Linux system. There are two ways to do it: Using the QEMU CLI or with virt-manager, which is a graphical user interface for QEMU/KVM. The choice depends on you!
But before that, make sure that you have downloaded the ISO image for the operating system you want to install. If you're still undecided, check out this list of the best Linux distributions for beginner, intermediate, and advanced users.
Create a new KVM on Arch Linux using virt-manager
If you are a beginner or don't want to deal with Linux terminal, the best way to create KVM on Arch Linux is to use virt-manager. It's easy to use and has a clean interface, similar to other GUI hypervisors like VirtualBox and VMware.
Start by launching virt-manager. Normally, it will appear as Virtual Machine Manager in the application menu, but you can also run the virt-manager command in the terminal to launch it.
When it launches, click Create a new virtual machine (just below the File option ). Select Local media install (ISO image or CDROM) and click Forward.
On the next screen, click Browse > Browse Local and select the downloaded ISO file. For this tutorial, install Manjaro, an Arch-based Linux distribution that has removed the complicated installation that Arch is famous for. With the file selected, click Forward.
If you see a prompt mentioning that the emulator may not have permission to search the path, just click Yes to continue.
Select the memory size and CPU cores for the virtual machine. In terms of memory, a quarter of actual physical memory is a good starting point.
For example, if you have 8GB of memory, anything between 2GB and 4GB will work. For CPU, enter the number of available cores (in this case 12). Click Forward to continue.
Next, configure the size of the KVM. 25GB would be more than enough to install Manjaro barebones or any other distro for that matter. Again, continue by clicking Forward.
Review the KVM information and click Finish if everything is fine. If you see a pop-up window Virtual Network is not active , select Yes to start the network.
virt-manager will start creating the KVM and as soon as it's done, a new virtual machine window will appear.
New KVM Configuration on Arch Linux Using QEMU CLI
To create a KVM on Arch Linux from the command line, you can use the qemu commands. To get started, first create a separate folder for the virtual machine and move the downloaded OS ISO file into the newly created folder:
mkdir kvm mv /path/to/linux-distro.iso ./kvm
Then create a 20G image file that will store KVM's data:
qemu-img create -f qcow2 Image.img 20G
Proceed by running the following command to start the virtual machine:
qemu-system-x86_64 -enable-kvm -cdrom linux-distro.iso -boot menu=on -drive file=Image.img -m 4G -cpu host -vga virtio -display sdl,gl=on
Make sure to replace linux-distro.iso in the above command with the correct file name and path. You can also change the value of the -m flag to configure how much memory you want to allocate to KVM.
A new virtual machine window will appear. Please check or install the operating system.
After installing the operating system to the image file, you do not need the -cdrom flag in the above command, because you will not be booting from the ISO file anymore. Instead, run:
qemu-system-x86_64 -enable-kvm -boot menu=on -drive file=Image.img -m 4G -cpu host -vga virtio -display sdl,gl=on
You can shorten the above command by creating a command line alias for it.
You should read it
May be interested
- Arch Linux for WSL is now available in Microsoft Storemicrosoft 's attitude towards linux has changed almost 180 degrees when, in the past, even companies had considered' linux is a cancer '(linux is a cancer), but now it is' i lucky có sự gọi linux a bệnh tử, nhưng mà bạn yêu cầu nó.
- How to Update Arch Linuxhow long has it been since you updated your arch linux system? whether you're using pure arch or arch-based distros like manjaro and garuda linux, updating the system is generally not complicated.
- 5 distributions based on the best Arch Linuxarch linux is one of the most popular linux distributions. but using arch linux is also a difficult challenge, making experienced linux users flinch.
- Is Arch Linux better than Ubuntu?arch linux and ubuntu are two big names in the linux world. both have a huge fan base, with two completely opposite positions.
- How to install Snap application in Arch Linuxsnap applications, or snapshots, are not dependent on the distribution, so ideally they will run the same on any system.
- Steps to install windows 11 on virtual machine, how to install windows 11 on VMwarein this article, tipsmake.com will show you how to install and experience windows 11 on a vmware virtual machine. this installation method helps you have a smooth running version of windows 11 with an internet connection.
- How to Install Visual Studio Code on Arch Linuxif you have a knack for coding, you may already be familiar with visual studio code. vs code is a much-loved tool, with fancy plug-ins and many useful features.
- Running Linux on Windows 10 does not require a virtual machine, here are 18 things you should knowthe windows subsystem for linux (wsl) feature - also called bash, helps programmers run ubuntu directly on windows without the need for a virtual machine. the following article will help readers better understand linux tools - wsl.
- How to Create an ARM-Based Linux Virtual Machine with Azurethe number of arm computers is increasing. if you want solid proof, look no further than the new arm-based macbook or the pocket-sized raspberry pi.
- Kali Linux installation instructions on VMware virtual machine in the most detailedfull guide on how to install kali linux on a vmware virtual computer, detailed to the teeth. how to install kali linux operating system on a virtual computer is extremely simple