Skip to content

CachyOS Virtualization Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

CachyOS Virtualization Guide

Complete beginner-friendly guide to virtualization on CachyOS, including QEMU/KVM, virt-manager, containers, and virtualization optimization.


Table of Contents

  1. Understanding Virtualization
  2. QEMU/KVM Setup
  3. virt-manager Configuration
  4. Creating Virtual Machines
  5. GPU Passthrough
  6. Container Virtualization
  7. Performance Optimization
  8. Troubleshooting

Understanding Virtualization

What is Virtualization?

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

Virtualization Types

Full virtualization:

  • QEMU/KVM: Hardware virtualization
  • VMware: Commercial virtualization
  • VirtualBox: Cross-platform virtualization

Container virtualization:

  • Docker: Application containers
  • Podman: Docker alternative
  • LXC: System containers

Benefits

Why use virtualization:

  • Testing: Test software safely
  • Isolation: Isolate applications
  • Multiple OS: Run different operating systems
  • Development: Development environments
  • Security: Isolated environments

QEMU/KVM Setup

What is QEMU/KVM?

QEMU/KVM is Linux virtualization technology.

  • KVM: Kernel-based Virtual Machine (kernel module)
  • QEMU: Emulator that uses KVM
  • Together: Full hardware virtualization

Checking Hardware Support

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/cpuinfo

What this does:

  • Checks if virtualization is enabled
  • Should show vmx or svm
  • If empty, enable in BIOS

Installing QEMU/KVM

Install packages:

sudo pacman -S qemu-full virt-manager virt-viewer dnsmasq vde2 bridge-utils openbsd-netcat libguestfs

What 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-full

Starting Services

Start libvirtd:

sudo systemctl enable --now libvirtd.service

What this does:

  • Enables libvirtd at boot
  • Starts libvirtd immediately
  • Required for virtualization

Check status:

sudo systemctl status libvirtd

What this does:

  • Shows service status
  • Verifies it's running
  • Should show "active (running)"

Add user to libvirt group:

sudo usermod -aG libvirt $USER

What this does:

  • Adds user to libvirt group
  • Allows managing VMs without sudo
  • Log out and back in for changes

virt-manager Configuration

What is virt-manager?

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

Launching virt-manager

From terminal:

virt-manager

From application menu:

  • Search for "Virtual Machine Manager"
  • Click to launch

virt-manager Interface

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

Creating Virtual Machines

Using virt-manager Wizard

Create new VM:

  1. Click "Create New Virtual Machine"
  2. Choose installation method:
  • Local install media: ISO file
  • Network install: Network installation
  • Import existing disk: Use existing disk
  1. Select ISO file or installation source
  2. Configure resources:
  • RAM: Memory allocation
  • CPU: CPU cores
  • Disk: Storage size
  1. Name VM and finish

VM Configuration

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

Installing Guest OS

Boot from ISO:

  1. Start VM
  2. VM boots from ISO
  3. Follow OS installation
  4. Install guest OS normally

Guest additions:

  • SPICE tools: Better graphics/input
  • QEMU guest agent: Better integration
  • Install in guest OS

GPU Passthrough

What is GPU Passthrough?

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

Requirements

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 iommu

What this does:

  • Checks IOMMU support
  • Should show IOMMU enabled
  • Required for passthrough

Enabling IOMMU

Edit GRUB:

sudo nano /etc/default/grub

For 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.cfg

Reboot:

sudo reboot

Configuring Passthrough

Find GPU:

lspci | grep -i vga

What this does:

  • Lists graphics cards
  • Shows GPU PCI addresses
  • Needed for passthrough

Configure VM:

  1. Open VM in virt-manager
  2. Add hardware → PCI Host Device
  3. Select GPU
  4. Configure and start VM

See Virt-manager Installation Guide for detailed GPU passthrough


Container Virtualization

What are Containers?

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

Docker

Install Docker:

sudo pacman -S docker

Start Docker:

sudo systemctl enable --now docker.service

Add user to docker group:

sudo usermod -aG docker $USER

What this does:

  • Allows using Docker without sudo
  • Log out and back in

Test Docker:

docker run hello-world

What this does:

  • Runs test container
  • Verifies Docker works
  • Shows Docker is working

Podman

Install Podman:

sudo pacman -S podman

What Podman does:

  • Docker alternative
  • Rootless by default
  • No daemon needed

Use Podman:

podman run hello-world

What this does:

  • Runs container with Podman
  • Works like Docker
  • No sudo needed

Performance Optimization

VM Performance

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

Resource Allocation

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

Troubleshooting

VM Won't Start

Check libvirtd:

sudo systemctl status libvirtd

What this does:

  • Checks libvirtd status
  • Should be running
  • Restart if needed

Check logs:

journalctl -u libvirtd

What this does:

  • Shows libvirtd logs
  • Helps identify issues
  • Check for errors

Network Issues

Check network:

virsh net-list --all

What this does:

  • Lists virtual networks
  • Shows network status
  • Helps troubleshoot

Start default network:

virsh net-start default
virsh net-autostart default

What this does:

  • Starts default network
  • Enables at boot
  • Fixes network issues

Performance Issues

Check resources:

htop

What this does:

  • Shows resource usage
  • Identifies bottlenecks
  • Helps optimize

Reduce VM resources:

  • Lower CPU cores
  • Reduce memory
  • Close other applications

Additional Resources


Summary

This guide covered:

  1. Understanding virtualization - What it is and types
  2. QEMU/KVM setup - Installing and configuring
  3. virt-manager - GUI for managing VMs
  4. Creating VMs - VM creation and configuration
  5. GPU passthrough - Direct GPU access
  6. Containers - Docker and Podman
  7. Performance optimization - Improving VM performance
  8. 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.

Clone this wiki locally