This repository contains either a Bash script or a guide to install and configure KVM (Kernel-based Virtual Machine), QEMU, and Virt-Manager on systems based on Arch Linux, Manjaro, Debian, Ubuntu, and Fedora.
- Prerequisites
- Installation with the Script
- Manual Installation
- After the Script
- Firewall and Security
- A system based on Arch Linux, Ubuntu, Debian, or Fedora with sudo access.
- An active internet connection to download the necessary packages.
- Git installed on your system:
- Archlinux / Manjaro:
sudo pacman -S git
- Fedora:
sudo dnf install -y git
- Debian / Ubuntu:
sudo apt update && sudo apt install -y git
- Archlinux / Manjaro:
- Your processor must support virtualization (Intel VT-x or AMD-V).
- Intel VT-x or AMD-V virtualization must be enabled in the BIOS.
Clone the repository and execute the installation script:
git clone https://github.com/Cardiacman13/kvm-qemu-virt-manager.git
cd KVM-QEMU-Virt-Manager
chmod +x install.sh
sudo ./install.sh
- System Update: Updates the packages on your system to ensure all dependencies are current.
- Package Installation: Installs QEMU, Virt-Manager, and other necessary tools for VM management.
- Permission Configuration: Configures
/etc/libvirt/libvirtd.conf
to allow the current user to manage VMs and adds the user to thelibvirt
group. - Restarting Necessary Services: Restarts the services so that the changes take effect immediately.
Install the necessary packages for KVM, QEMU, and other virtualization management tools:
Archlinux:
sudo pacman -S qemu-full virt-manager virt-viewer dnsmasq vde2 bridge-utils openbsd-netcat dmidecode libguestfs
Fedora:
sudo dnf install -y @virtualization
Debian / Ubuntu:
sudo apt update
sudo apt install -y virt-manager
Enable and start the libvirtd
service:
sudo systemctl enable --now libvirtd.service
Modify the configurations to allow the user to use KVM:
sudo sed -i 's/#unix_sock_group = "libvirt"/unix_sock_group = "libvirt"/' /etc/libvirt/libvirtd.conf
sudo sed -i 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/' /etc/libvirt/libvirtd.conf
sudo systemctl restart libvirtd.service
Add your user to the libvirt
and kvm
groups:
sudo usermod -a -G libvirt $(whoami)
sudo usermod -a -G kvm $(whoami)
After completing the configuration, it is recommended to reboot your system so that all changes take effect:
sudo reboot
You will just need to activate the connection as shown in the screenshot below, and you are ready to create a VM.
Firewalls can sometimes block the connections necessary for the proper functioning of KVM, QEMU, and Virt-Manager. Ensure that the firewall rules allow the following connections:
- TCP/UDP Ports: The ports used by
libvirtd
and virtual machines must be open. - Specific Services: Allow the
libvirtd
andvirt-manager
services in your firewall.
To configure the firewall, you can use tools like ufw
(Uncomplicated Firewall) on Debian/Ubuntu or firewalld
on Fedora. Here are some example commands:
sudo ufw allow libvirtd
sudo ufw allow virt-manager
sudo ufw reload
sudo firewall-cmd --add-service=libvirt --permanent
sudo firewall-cmd --add-service=virt-manager --permanent
sudo firewall-cmd --reload
By following these steps, you should be able to correctly configure your environment to use KVM, QEMU, and Virt-Manager without being blocked by firewall rules.