- How To Install KVM on Manjaro 21
- Install KVM on Manjaro 21 Ornara
- Installing KVM/QEMU/virt-manager on Manjaro Linux(Arch Linux)
- 1. QEMU Installation #
- 2. Virt-Manager and libvirtd Service Install #
- 3. Start the Services #
- Lean Approach
- 4. Configure the KVM #
- 5. Creating an New Network Bridge for VM. #
- 5.1 Create the Bridge description file #
- 5.2. Register the Bridge Network: #
- 5.3. Start the Bridge #
- Lean Approach
- 6. Permissions for Current User #
- 7. Reboot #
- More Notes #
- Windows — Guest — Copy & Paste Clipboard #
- Remote Connection to Display of VM #
- Multiple Monitors for a VM #
- Adding more USB devices to a VM #
- CPU Pinning Video — Easy #
- CPU Pinning Detail #
- Wish you All the Best #
- References #
How To Install KVM on Manjaro 21
In this tutorial, we will show you how to install KVM on Manjaro 21. For those of you who didn’t know, KVM stands for Kernel-based Virtual Machine which allows us to run multiple guests operating systems on a single host. KVM is an Open-source technology that lets us turn our Linux machine into a Hypervisor. This allows us to run multiple Virtual Machines (VMs). The KVM converts Linux into a (bare-metal) hypervisor. Implementations of KVM are supported on the x86 platforms (32-bit and 64-bit) that support virtualization CPU extensions (such as those provided in Intel VT and AMD-V lines). The only exceptions are the Atom processor from Intel.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘ sudo ‘ to the commands to get root privileges. I will show you the step-by-step installation of the KVM on a Manjaro 21 (Ornara).
Prerequisites
- A server running one of the following operating systems: Manjaro 21.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- A non-root sudo user or access to the root user . We recommend acting as a non-root sudo user , however, as you can harm your system if you’re not careful when acting as the root.
Install KVM on Manjaro 21 Ornara
Step 1. Before running the tutorial below, make sure that our system is up to date:
Step 2. Installing KVM on Manjaro 21.
Now we check if your system supports hardware virtualization. To do so, run the following command:
lscpu | grep Virtualization
[root@idroot.us ~]# lscpu | grep Virtualization Virtualization: VT-x Virtualization type: full
Next, we need to check the Kernel support on our system. Run the command below to check:
zgrep CONFIG_KVM /proc/config.gz
CONFIG_KVM_GUEST=y CONFIG_KVM_MMIO=y CONFIG_KVM_ASYNC_PF=y CONFIG_KVM_VFIO=y CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT=y CONFIG_KVM_COMPAT=y CONFIG_KVM_XFER_TO_GUEST_WORK=y CONFIG_KVM=m CONFIG_KVM_INTEL=m CONFIG_KVM_AMD=m CONFIG_KVM_AMD_SEV=y CONFIG_KVM_MMU_AUDIT=y
Once done, now install KVM and all the dependencies:
sudo pacman -S virt-manager qemu vde2 ebtables dnsmasq bridge-utils openbsd-netcat
Run the Virtual Machine Manager after installation is complete:
sudo systemctl enable libvirtd.service sudo systemctl start libvirtd.service
Now we open the /etc/libvirt/libvirtd.conf for editing:
sudo nano /etc/libvirt/libvirtd.conf
Now uncomment the following line
Also, we need to uncomment this line
Once done, close and save the file.
Step 4. Accessing KVM on Manjaro Linux.
Once successfully installed, now we are ready to create our first virtual machine. Open the Virtual Machine Manager from the Application menu.
Congratulations! You have successfully installed KVM. Thanks for using this tutorial for installing the latest version of KVM on the Manjaro system. For additional help or useful information, we recommend you check the official KVM website.
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!
Installing KVM/QEMU/virt-manager on Manjaro Linux(Arch Linux)
KVM is an inherently better way to work with Virtual Machines. It sands for Kernel Virtual Machine.
UPDATED: 12th Oct 2020 — Bridge Network fix and added more details on remote viewing.
Let’s Look at what steps I followed.
1. QEMU Installation #
sudo pacman -S qemu qemu-arch-extra ovmf bridge-utils dnsmasq vde2 \ openbsd-netcat ebtables iptables
- ovmf helps to do the UEFI Bios and Secure Boot setups.
- bridge-utils for network bridge needed for VMs
- vde2 for QEMU distributed ethernet emulation
- dnsmasq the DNS forwarder and DHCP server
- openbsd-netcat network testing tool (Optional)
- ebtables and iptables to create packet routing and firewalls
2. Virt-Manager and libvirtd Service Install #
Virt-manager is a UI that helps to create and organize the VM’s. And virt-viewer is used to open remote window into the VM instance.
sudo pacman -S virt-manager virt-viewer
3. Start the Services #
To Autostart the services at boot:
# Enable Auto-Start of the Service sudo systemctl enable libvirtd.service # Start the Service Right now sudo systemctl start libvirtd.service
In case you wish to see if the libvirtd.service has actually started or not:
sudo systemctl status libvirtd.service
Lean Approach
Note: In order to reduce the system Load you can skip the Autostart part. And do it every time you wish to use the service.
Just run, whenever you wish to work with KVM:
# Start the Service Right now sudo systemctl start libvirtd.service
4. Configure the KVM #
Open the /etc/libvirt/libvirtd.conf for editing
sudo nano -cl /etc/libvirt/libvirtd.conf
Here are the Lines to Edit:
- Uncomment the line 81 or so:
Make sure to save the file before you exit.
5. Creating an New Network Bridge for VM. #
A new network bridge is needed allow a separate IP subnet for Guest OS’s in VM.
5.1 Create the Bridge description file #
Create a new file like br10.xml :
And type the content in br10.xml :
1 2 3 4 5 6 7 8 9 10 11 12 13 14
br10 mode='nat'> start='1024' end='65535'/> name='br10' stp='on' delay='0'/> address='192.168.72.1' netmask='255.255.255.0'> start='192.168.72.50' end='192.168.72.200'/>
This would help to register a new bridge network for the Guest OS’s. Here we are changing the default IP Address 192.168.72.X and also allowing the specific ports 1024-65535 to be forwarded over NAT. This helps to easily communicate with the Guest OS in the VM’s.
5.2. Register the Bridge Network: #
sudo virsh net-define /tmp/br10.xml
Now we have the network registered in the libvirtd .
5.3. Start the Bridge #
To Start this network bridge:
If you want to permanently enable the new network bridge, so that it Autostart at boot:
sudo virsh net-autostart br10
Lean Approach
Note: Permanently enabling this network would take resources. Hence the start command must be given every time before starting virt-manager .
6. Permissions for Current User #
In-order to be able to use the virt-manager as normal user, we need to add the user to the libvirt group.
sudo usermod -a -G libvirt $(whoami)
7. Reboot #
Yes, for all this to take effect we need to reboot the computer.
More Notes #
Here are few insights that I found while using the virt-manager .
Windows — Guest — Copy & Paste Clipboard #
In order to make sure that the copy & paste works between the host and guest, we need to install Windows guest tools = spice-guest-tools .
Note This only works if your Display is set to spice Server .
Remote Connection to Display of VM #
Typically the VM’s in KVM are destined to run like head-less unit. Hence the remote viewer = virt-viewer is needed.
In order to connect to VM use the address
Thats the default port on which the virt-manager hosts the VM display output.
Multiple Monitors for a VM #
This is possible by adding few instances of Video QXL .
This can be done in the configuration mode of the VM’s (a.k.a i or show hardware details after opening the VM).
Adding more USB devices to a VM #
Some times we need to mount more than 1 USB device to our Guest OS. This can be easily achieved by adding more USB Redirector to the VM.
This can be done in the configuration mode of the VM’s (a.k.a i or show hardware details after opening the VM).
CPU Pinning Video — Easy #
Use this command to check the Topology and CPU numbers.
CPU Pinning Detail #
When thinking about CPUs, there are three concepts — socket, cores, and threads. 1
A socket (NUMA node) is a physical socket where the physical CPU capsules are placed. A normal PC only has one socket.
Cores are the number of CPU-cores per CPU. A modern standard CPU for a standard PC usually has two to four cores. Some CPUs can run more than one parallel thread per CPU-core. Intel has either one or two threads per core depending on the CPU model.
When lscpu says CPU(s) , it means Socket(s) * Core(s) per socket * Thread(s) per core . virt-manager ’s Logical host CPUs also means the same thing.
The default behavior of KVM guests is to run operations coming from the guest as a number of threads representing virtual processors. 2 Those threads are managed by the Linux scheduler.
CPU pinning limits which physical CPU cores the virtual CPUs are allowed to run on.
The ideal setup is one-to-one mapping such that virtual CPU cores match physical CPU cores while taking hyperthreading/SMT into account.
Hyperthreading/SMT is simply a very efficient way of running two threads on one CPU core at any given time.
The topology of the processor can be found out using lscpu -e . Column CORE shows the association of the physical/logical CPU cores.
In case of ThinkPad we have the following.
[demo@pc1:~]$ lscpu -e CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE MAXMHZ MINMHZ 0 0 0 0 0:0:0:0 yes 2800.0000 400.0000 1 0 0 1 1:1:1:0 yes 2800.0000 400.0000 2 0 0 0 0:0:0:0 yes 2800.0000 400.0000 3 0 0 1 1:1:1:0 yes 2800.0000 400.0000
So CORE 0 has CPU 0, 2 and CORE 1 has CPU 1, 3.
So, if we want to allocate CORE 1 to the VM, we would have to do virsh edit vmname and do the following.
placement="static">2 vcpu='0' cpuset='1' /> vcpu='1' cpuset='3' />
Wish you All the Best #
Hope this would helpful to get you stared on KVM using QEMU and virt-manager as the front-end.
As always, I look forward to your suggestion and comments. DM me on Mastodon .
References #
- Even Better Expanation https://ermannoferrari.net/kvm-on-arch-linux
- Video Explaining the Install Process https://www.youtube.com/watch?v=t-VpMbWzPZI
- Steps In detail https://computingforgeeks.com/complete-installation-of-kvmqemu-and-virt-manager-on-arch-linux-and-manjaro/
- Alternate Steps https://cubiclenate.com/2019/06/11/virtual-machine-manager-with-qemu-kvm-on-opensuse-tumbleweed/
- Another Alternative https://www.fosslinux.com/2484/how-to-install-virtual-machine-manager-kvm-in-manjaro-and-arch-linux.htm
- Arch WiKi explaining the things to have QEMU Install working correctly https://wiki.archlinux.org/index.php/QEMU#Installation
- https://stackoverflow.com/a/40163228↩︎
- https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#CPU_pinning↩︎