Setup QEMU/KVM on Arch Linux

INTRODUCTION
Virtualization on Arch Linux often feels confusing, especially for users coming from VirtualBox or VMware.
These tools are great for beginners, but they consume a lot of system resources and can slow down the overall experience.
In this guide, we will use QEMU with KVM acceleration, a faster and more efficient virtualization solution built directly into the Linux kernel.
It gives you better performance, lower resource usage, and a smoother workflow on Arch Linux.
System Requirements
- Virtualization Enabled in BIOS
- Stable Internet Connection
- Basic Terminal Settings
Installation guide
- Execute Below command
sudo pacman -S qemu-full qemu-img libvirt virt-install virt-manager virt-viewer \
edk2-ovmf dnsmasq swtpm guestfs-tools libosinfo tuned
- This are services required to be running to run the qemu but recommend instead of enabling them which will start them when the system boot increasing the resource usage i suggest just start them when u require them
-
- Option : Enable modular daemon
for drv in qemu interface network nodedev nwfilter secret storage; do
sudo systemctl restart virt${drv}d.service;
sudo systemctl restart virt${drv}d{,-ro,-admin}.socket;
done
-
- Option : Enable monolithic daemon
sudo systemctl enable libvirtd.service
-
if you want we can enable nested nested virtualization its based on your use case (optional)
1. Temporary sessionFor Intel
sudo modprobe -r kvm_intel
sudo modprobe kvm_intel nested=1
for AMD
sudo modprobe -r kvm_amd
sudo modprobe kvm_amd nested=1
- Permanent Session
For Intel
echo "options kvm_intel nested=1" | sudo tee /etc/modprobe.d/kvm-intel.conf
For AMD
echo "options kvm_amd nested=1" | sudo tee /etc/modprobe.d/kvm-amd.conf
—————————————————————————————————————
Enabling IMMOMU (FOR INTEL )
IOMMU = Input–Output Memory Management Unit
Think of it like a traffic controller for hardware devices.
It controls how PCI devices (GPU, USB controllers, NVMe disks, etc.) access system memory. without it:
-
You cannot assign hardware directly to a virtual machine
-
GPU passthrough will not work
-
Device isolation becomes weak
-
Security decreases
- Open your GRUB config
sudo vim /etc/default/grub
- Add following kernel module entries
#/etc/default/grub
GRUB_CMDLINE_LINUX="... intel_iommu=on iommu=pt"
- Regenerate the grub config
sudo grub-mkconfig -o /boot/grub/grub.cfg
- Set Profile to
virtual-hostfor tuned
sudo tuned-adm profile virtual-host
————————————————————————————————————
ENABLE SEV (FOR AMD)
Option 1 : ENABLE SEV IN AMD using modproble
echo "options kvm_amd sev=1" | sudo tee /etc/modprobe.d/amd-sev.conf
sudo reboot now
Option 2 : ENABLE SEV IN AMD USING GRUB
- Open your grub config file
sudo vim /etc/default/grub
- Add following lines to the file
GRUB_CMDLINE_LINUX="... mem_encrypt=on kvm_amd.sev=1"
3.Regenerate the grub config
sudo grub-mkconfig -o /boot/grub/grub.cfg
sudo reboot now
——————————————————————————————————————-
OPTIMIZING HOST WITH TUNED
- Enable TuneD at startup
sudo systemctl enable --now tuned.service
- Check Active profile
tuned-adm active
- Set profile to
virtual-host
sudo tuned-adm profile virtual-host