-
-
Notifications
You must be signed in to change notification settings - Fork 2
CachyOS Virtualization Guide
Complete beginner-friendly guide to virtualization on CachyOS, including QEMU/KVM, virt-manager, containers, and virtualization optimization.
- Understanding Virtualization
- QEMU/KVM Setup
- virt-manager Configuration
- Creating Virtual Machines
- GPU Passthrough
- Container Virtualization
- Performance Optimization
- Troubleshooting
Virtualization allows running multiple operating systems on one computer.
What it does:
- Creates VMs: Virtual machines (isolated environments)
- Runs multiple OS: Different operating systems simultaneously
- Isolates systems: VMs are separate from host
- Resource sharing: Shares CPU, RAM, disk with host
Full virtualization:
- QEMU/KVM: Hardware virtualization
- VMware: Commercial virtualization
- VirtualBox: Cross-platform virtualization
Container virtualization:
- Docker: Application containers
- Podman: Docker alternative
- LXC: System containers
Why use virtualization:
- Testing: Test software safely
- Isolation: Isolate applications
- Multiple OS: Run different operating systems
- Development: Development environments
- Security: Isolated environments
QEMU/KVM is Linux virtualization technology.
- KVM: Kernel-based Virtual Machine (kernel module)
- QEMU: Emulator that uses KVM
- Together: Full hardware virtualization
Check CPU virtualization support:
lscpu | grep -E "vmx|svm"What this does:
- Checks CPU virtualization features
-
vmx: Intel VT-x -
svm: AMD-V - Need one of these
Check if enabled:
grep -E "vmx|svm" /proc/cpuinfoWhat this does:
- Checks if virtualization is enabled
- Should show vmx or svm
- If empty, enable in BIOS
Install packages:
sudo pacman -S qemu-full virt-manager virt-viewer dnsmasq vde2 bridge-utils openbsd-netcat libguestfsWhat these packages do:
-
qemu-full: Full QEMU emulator -
virt-manager: GUI for managing VMs -
virt-viewer: VM display viewer -
dnsmasq: Network management -
bridge-utils: Network bridging -
libguestfs: Guest filesystem tools
Or use package group:
sudo pacman -S virt-manager qemu-fullStart libvirtd:
sudo systemctl enable --now libvirtd.serviceWhat this does:
- Enables libvirtd at boot
- Starts libvirtd immediately
- Required for virtualization
Check status:
sudo systemctl status libvirtdWhat this does:
- Shows service status
- Verifies it's running
- Should show "active (running)"
Add user to libvirt group:
sudo usermod -aG libvirt $USERWhat this does:
- Adds user to libvirt group
- Allows managing VMs without sudo
- Log out and back in for changes
virt-manager is a graphical tool for managing virtual machines.
What it does:
- Create VMs: Easy VM creation wizard
- Manage VMs: Start, stop, configure VMs
- Monitor VMs: View VM performance
- Configure VMs: Change VM settings
From terminal:
virt-managerFrom application menu:
- Search for "Virtual Machine Manager"
- Click to launch
Main window:
- VM list: Shows all VMs
- Toolbar: Create, start, stop VMs
- Status: Shows VM status
VM details:
- Overview: General VM info
- Performance: CPU, memory usage
- Hardware: VM hardware configuration
Create new VM:
- Click "Create New Virtual Machine"
- Choose installation method:
- Local install media: ISO file
- Network install: Network installation
- Import existing disk: Use existing disk
- Select ISO file or installation source
- Configure resources:
- RAM: Memory allocation
- CPU: CPU cores
- Disk: Storage size
- Name VM and finish
CPU settings:
- Cores: Number of CPU cores
- Threads: CPU threads per core
- CPU model: CPU type to emulate
Memory settings:
- RAM: Amount of memory
- Ballooning: Dynamic memory (optional)
Storage settings:
- Disk size: Virtual disk size
- Disk format: qcow2 (recommended)
- Storage pool: Where to store disk
Network settings:
- NAT: Default (VM can access internet)
- Bridge: Direct network access
- Isolated: No network access
Boot from ISO:
- Start VM
- VM boots from ISO
- Follow OS installation
- Install guest OS normally
Guest additions:
- SPICE tools: Better graphics/input
- QEMU guest agent: Better integration
- Install in guest OS
GPU passthrough gives VM direct access to GPU.
What it does:
- Direct GPU access: VM uses real GPU
- Better performance: Near-native GPU performance
- Gaming: Play games in VM
- GPU computing: Use GPU for computation
Hardware requirements:
- Two GPUs: One for host, one for VM
- IOMMU support: CPU/BIOS support
- Compatible hardware: Check compatibility
Check IOMMU support:
dmesg | grep -i iommuWhat this does:
- Checks IOMMU support
- Should show IOMMU enabled
- Required for passthrough
Edit GRUB:
sudo nano /etc/default/grubFor Intel:
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on iommu=pt"
For AMD:
GRUB_CMDLINE_LINUX_DEFAULT="amd_iommu=on iommu=pt"
Update GRUB:
sudo grub-mkconfig -o /boot/grub/grub.cfgReboot:
sudo rebootFind GPU:
lspci | grep -i vgaWhat this does:
- Lists graphics cards
- Shows GPU PCI addresses
- Needed for passthrough
Configure VM:
- Open VM in virt-manager
- Add hardware → PCI Host Device
- Select GPU
- Configure and start VM
See Virt-manager Installation Guide for detailed GPU passthrough
Containers are lightweight virtualization.
What they do:
- Isolate applications: Separate application environments
- Share kernel: Use host kernel (lighter)
- Fast startup: Start quickly
- Resource efficient: Use fewer resources
Install Docker:
sudo pacman -S dockerStart Docker:
sudo systemctl enable --now docker.serviceAdd user to docker group:
sudo usermod -aG docker $USERWhat this does:
- Allows using Docker without sudo
- Log out and back in
Test Docker:
docker run hello-worldWhat this does:
- Runs test container
- Verifies Docker works
- Shows Docker is working
Install Podman:
sudo pacman -S podmanWhat Podman does:
- Docker alternative
- Rootless by default
- No daemon needed
Use Podman:
podman run hello-worldWhat this does:
- Runs container with Podman
- Works like Docker
- No sudo needed
CPU pinning:
- Pin VM CPUs to specific cores
- Reduces CPU overhead
- Better performance
Huge pages:
- Use huge pages for memory
- Better memory performance
- Configure in VM settings
VirtIO drivers:
- Use VirtIO for disk/network
- Better performance than emulated
- Install in guest OS
CPU allocation:
- Don't overallocate CPUs
- Leave resources for host
- Monitor CPU usage
Memory allocation:
- Don't overallocate memory
- Leave RAM for host
- Use memory ballooning
Disk I/O:
- Use SSD for VM storage
- Separate disk for VMs
- Better I/O performance
Check libvirtd:
sudo systemctl status libvirtdWhat this does:
- Checks libvirtd status
- Should be running
- Restart if needed
Check logs:
journalctl -u libvirtdWhat this does:
- Shows libvirtd logs
- Helps identify issues
- Check for errors
Check network:
virsh net-list --allWhat this does:
- Lists virtual networks
- Shows network status
- Helps troubleshoot
Start default network:
virsh net-start default
virsh net-autostart defaultWhat this does:
- Starts default network
- Enables at boot
- Fixes network issues
Check resources:
htopWhat this does:
- Shows resource usage
- Identifies bottlenecks
- Helps optimize
Reduce VM resources:
- Lower CPU cores
- Reduce memory
- Close other applications
- Virt-manager Installation Guide - Detailed virt-manager setup
- CachyOS System Tweaks - Performance optimizations
- Arch Linux Wiki - QEMU: https://wiki.archlinux.org/title/QEMU
- Arch Linux Wiki - KVM: https://wiki.archlinux.org/title/KVM
This guide covered:
- Understanding virtualization - What it is and types
- QEMU/KVM setup - Installing and configuring
- virt-manager - GUI for managing VMs
- Creating VMs - VM creation and configuration
- GPU passthrough - Direct GPU access
- Containers - Docker and Podman
- Performance optimization - Improving VM performance
- Troubleshooting - Common issues
Key Takeaways:
- QEMU/KVM provides full virtualization
- virt-manager is easy GUI for VMs
- Check CPU virtualization support
- Enable libvirtd service
- Use VirtIO for better performance
- GPU passthrough requires two GPUs
- Containers are lighter than VMs
- Monitor resources to avoid overallocation
This guide is based on the CachyOS Wiki and Arch Linux Wiki and expanded with detailed explanations for beginners. For the most up-to-date virtualization information, always refer to the official documentation.