The basic steps to get KVM virtual machines using libvirt and virt-manager ready to go on an Arch box.
Notes:
- NAT'ed: These will be using network address translation (NAT) and not be bridged.
See Virsh Bridge for steps to create a bridge network. - There are easier ways to get images than downloading raw ISOs.
See QCow Cloud Images for more details.
Prep
# Check for virtualization support (should return a value)
grep -E '(vmx|svm)' /proc/cpuinfo
# Update system: refresh databases and upgrade all installed packages.
sudo pacman -Syu
Install Packages
sudo pacman -S qemu-full libvirt virt-install \
bridge-utils iptables-nft edk2-ovmf \
dnsmasq
Enable & Start libvirt services
# Start and enable the daemon
sudo systemctl enable --now libvirtd
sudo systemctl start libvirtd
Add your user to libvirt group.
# Add your user to the libvirt group (requires logout/login to take effect)
sudo usermod -aG libvirt $USER
# logout/reboot to have your terminal become part of that group
groups # you should see libvirt listed
Enable Default NAT Network
Start and autostart the default network for VMs
sudo virsh net-start default
sudo virsh net-autostart default
Check it with virsh net-list --all
create a VM test
You'll need an iso image to install from, go grab Arch's iso
virt-install \
--name arch-test \
--memory 4096 \
--vcpus 4 \
--cpu host \
--disk size=40 \
--cdrom /path/to/linux.iso \
--os-variant archlinux \
--network network=default \
--graphics none \
--console pty,target_type=serial \
--boot uefi
Connect to console with
virsh console arch-test
Exist the console using Ctrl = ]
Management Commands
- Start VM:
virsh start arch-test - Shutdown VM:
virsh shutdown arch-test - Force stop:
virsh destroy arch-test - List VMs:
virsh list --all - Delete VM:
virsh undefine arch-test --remove-all-storage
Sanity Checks
Run these to verify your environment is healthy:
groups
You should seelibvirtlistedlsmod | grep kvm
Verifies the KVM kernel modules are loaded.virsh net-list --all
Checks if the default NAT network is active.virsh list --all
Lists all defined VMs and their statuses.