Install VirtManager for KVM on Arch Linux
VirtManager (Virtual Machine Manager) is a graphical interface used to manage virtual machines via KVM (Kernel-based Virtual Machine) on Linux. It's widely used because of its simplicity and user-friendly interface for creating, managing, and configuring virtual machines. If you’re using Arch Linux, the installation process is straightforward. This guide will walk you through the steps to install and set up VirtManager for KVM on Arch Linux.
Step 1: Install Required Packages
If you haven't already installed KVM, Libvirt, and the required tools, use the following command to install them:
sudo pacman -S qemu libvirt virt-manager bridge-utils libguestfs nano
This will install KVM, Libvirt, VirtManager, libguestfs, and Nano (for editing configuration files).
Step 2: Edit the libvirtd Configuration
- Find and modify the following settings:This ensures that only the
libvirt
group has read and write access to the UNIX domain socket used by Libvirt. - Set the UNIX socket permissions for the R/W socket:Around line 102, change the
unix_sock_rw_perms
line to:
unix_sock_rw_perms = "0770"
- Set the UNIX domain socket group ownership to
libvirt
:Around line 85, change theunix_sock_group
line to:
unix_sock_group = "libvirt"
- Open the libvirtd.conf file for editing using Nano (or any text editor you prefer):
sudo nano /etc/libvirt/libvirtd.conf
Step 3: Add Your User to the libvirt
Group
To allow your standard user to manage virtual machines, you need to add your user to the libvirt group. Run the following command:
sudo usermod -a -G libvirt $(whoami)
This adds your current user to the libvirt
group, giving you the necessary permissions.
Step 4: Apply Group Changes
To apply the group changes immediately without logging out and back in, use the newgrp
command:
newgrp libvirt
This ensures that your user is immediately recognized as part of the libvirt
group for the current session.
sudo systemctl enable --now libvirtd.service
Step 5: Restart the libvirt Daemon
For the changes to take effect, you need to restart the libvirt daemon:
sudo systemctl restart libvirtd.service
This reloads the libvirtd service with the updated configuration.
If errors occurs, it is recommended to restart the computer.
Step 6: Verify the Setup
After making these changes, you should be able to use your normal user account to manage KVM and virtual machines without needing sudo
. You can verify by running VirtManager or using virsh commands.
For example, try running the following command to list all VMs (even if they aren't running):
virsh list --all
You should be able to see the list of virtual machines without requiring sudo
.
Conclusion
With these steps, you've configured your system to allow a standard Linux user account to manage KVM through Libvirt. By adjusting the permissions on the UNIX domain socket and adding your user to the libvirt
group, you’ve enabled secure access to virtualization tools such as VirtManager and virsh.