# Enable SPICE VDAgent servicesudo systemctl enable spice-vdagentdsudo systemctl start spice-vdagentd# Enable QEMU guest agentsudo systemctl enable qemu-guest-agentsudo systemctl start qemu-guest-agent# Verify services are runningsystemctl status spice-vdagentdsystemctl status qemu-guest-agent
Step 3: Graphics and Display Optimization
Install Graphics Drivers
# Install Mesa utilities for 3D accelerationsudo apt install mesa-utils# Install video acceleration librariessudo apt install va-driver-all vdpau-driver-all# Verify 3D acceleration is workingglxinfo | grep "direct rendering"# Should output: "direct rendering: Yes"# Check OpenGL versionglxinfo | grep "OpenGL version"
Configure Display Settings
In Ubuntu Settings → Displays
Set appropriate resolution
Enable fractional scaling if needed (may impact performance)
Step 4: System Performance Tuning
CPU Governor Settings
# Install CPU frequency utilitiessudo apt install cpufrequtils# Check current governorcpufreq-info | grep "governor"# Set to performance mode (temporary)sudo cpufreq-set -g performance# Make performance mode permanentecho 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtilssudo systemctl restart cpufrequtils
Reduce Swappiness
# Check current swappinesscat /proc/sys/vm/swappiness# Reduce swappiness (default is 60, reduce to 10)echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf# Apply immediatelysudo sysctl vm.swappiness=10
Enable TRIM for Virtual Disk
# Enable periodic TRIM (helps with disk performance)sudo systemctl enable fstrim.timersudo systemctl start fstrim.timer# Verify it's scheduledsystemctl status fstrim.timer
Step 5: Memory Optimization
Configure zRAM (Compressed RAM)
# Install zRAM toolssudo apt install zram-tools# Configure zRAM (creates compressed swap in RAM)echo -e "ALGO=lz4\nPERCENT=50" | sudo tee /etc/default/zramswapsudo service zramswap restart
Step 6: Ubuntu-Specific Optimizations
Disable Unnecessary Services
# Disable printer service if not neededsudo systemctl disable cupssudo systemctl stop cups# Disable Bluetooth if not neededsudo systemctl disable bluetoothsudo systemctl stop bluetooth
# Monitor system resourceshtop # Install with: sudo apt install htop# Check disk I/Oiotop # Install with: sudo apt install iotop# Monitor GPU/3D accelerationglxgears # Should show smooth animation
Benchmark (Optional)
# Install benchmark toolssudo apt install hardinfo sysbench# Run simple CPU benchmarksysbench cpu --cpu-max-prime=20000 run# Run memory benchmarksysbench memory run
Tips for Best Performance
Allocate Enough Resources: Give the VM at least 2 CPUs and 4GB RAM
Keep Host System Light: Close unnecessary applications on Pop!_OS
Regular Updates: Keep both host and guest systems updated
Restart After Optimization: Reboot the VM after applying these changes
Monitor Performance: Use system monitor to ensure optimizations are working
# On the host, check if KVM is loadedlsmod | grep kvm# If not loaded, load KVM modulessudo modprobe kvmsudo modprobe kvm_intel # For Intel CPUs# ORsudo modprobe kvm_amd # For AMD CPUs
”Virtualization not enabled” Error
Reboot your host system and enter BIOS/UEFI
Look for: Virtualization Technology, VT-x (Intel), AMD-V (AMD), or SVM
Enable the virtualization option
Save and exit BIOS
VM Crashes During Boot
In GNOME Boxes, right-click VM → Properties
Reduce RAM allocation (might be over-allocated)
Disable 3D acceleration temporarily
Try booting with 1 CPU core first
Display Issues
Resolution Won’t Change / Stuck at Low Resolution
# In the VM, reinstall SPICE agentsudo apt install --reinstall spice-vdagent# Restart the servicesudo systemctl restart spice-vdagentd# Force reload the kernel modulesudo modprobe -r vboxvideo # Remove if existssudo modprobe virtio-gpu# Manually set resolutionxrandr --output Virtual-1 --mode 1920x1080
No 3D Acceleration
# Check if 3D is workingglxinfo | grep "direct rendering"# If it shows "No", install driverssudo apt install mesa-utils libgl1-mesa-glx libgl1-mesa-dri# Check rendererglxinfo | grep "OpenGL renderer"# Should show "llvmpipe" or "virgl" for virtual GPU
Screen Tearing or Flickering
# Disable compositor effectsgsettings set org.gnome.desktop.interface enable-animations false# Or try a different compositorsudo apt install comptoncompton --backend glx --vsync opengl-swc &
Performance Issues
VM Running Very Slowly
# Check if KVM acceleration is being usedgrep -E 'vmx|svm' /proc/cpuinfo # On host# If no output, virtualization isn't enabled in BIOSPP# In the VM, verify KVM is being usedsudo apt install cpu-checkerkvm-ok# Should report "KVM acceleration can be used"# Check CPU governorcat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor# Set to performance if neededecho performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
High CPU Usage
# Find what's using CPUtop# Or for better interfacehtop# Common culprits:# - gnome-shell (try disabling extensions)# - tracker-miner (disable file indexing)sudo systemctl mask tracker-store.service tracker-miner-fs.service
Memory Issues
# Check memory usagefree -h# Clear cachessudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches# Check for memory leaksps aux --sort=-%mem | head -10
Clipboard Not Working
Clipboard Sharing Broken
# Check if spice-vdagent is installeddpkg -l | grep spice-vdagent# Reinstall if neededsudo apt install --reinstall spice-vdagent# Check if service is runningsystemctl status spice-vdagentd# Start manually if neededsudo systemctl start spice-vdagentd# Check for running agent processesps aux | grep vdagent# Should see both spice-vdagentd and spice-vdagent
Copy/Paste Only Works One Direction
# Kill and restart agentssudo killall spice-vdagentsudo systemctl restart spice-vdagentd# Check logs for errorsjournalctl -u spice-vdagentd -f
Network Problems
No Internet Connection
# Check network interfacesip addr show# Restart networksudo systemctl restart NetworkManager# Check DNScat /etc/resolv.conf# Should have nameserver entries# Set DNS manually if neededecho "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
Slow Network Speed
# Check current network driverlspci -k | grep -A 3 -i network# Should be using virtio driver# If not, the VM might be using e1000 (slower)# Test network speedsudo apt install speedtest-clispeedtest-cli
Shared Folders Not Working
Folder Not Appearing
# Check if spice-webdavd is installed and runningsystemctl status spice-webdavd# Install if missingsudo apt install spice-webdavd# Enable and startsudo systemctl enable spice-webdavdsudo systemctl start spice-webdavd# Check for mountsmount | grep webdav
Permission Denied on Shared Folder
# Check ownershipls -la /media/# Add user to necessary groupsudo usermod -aG fuse $USER# Logout and login again# If still not working, try manual mountsudo mkdir /mnt/sharedsudo chmod 777 /mnt/shared
Audio Issues
No Sound in VM
# Check audio devicespactl list short sinks# Install PulseAudio volume controlsudo apt install pavucontrolpavucontrol# Check if output device is correct# Restart PulseAudiopulseaudio -kpulseaudio --start
# At grub prompt, manually boot:grub> set root=(hd0,1)grub> linux /boot/vmlinuz root=/dev/sda1grub> initrd /boot/initrd.imggrub> boot# Once booted, repair GRUB:sudo update-grubsudo grub-install /dev/sda
Very Slow Boot Time
# Analyze bootsystemd-analyze blame# Disable unnecessary servicessudo systemctl disable snapd.servicesudo systemctl disable ModemManager.service# Remove quiet and splash for verbose boot (helps diagnose)sudo nano /etc/default/grub# Remove "quiet splash" from GRUB_CMDLINE_LINUX_DEFAULTsudo update-grub
VM Management Issues
Can’t Delete VM
Make sure VM is stopped
Try from command line:
# List VMsvirsh list --all# Force destroy if runningvirsh destroy "Ubuntu-VM-Name"# Undefine VMvirsh undefine "Ubuntu-VM-Name" --remove-all-storage
Snapshots Not Working
# Check disk space on hostdf -h# Clean up old snapshots in GNOME Boxes# Right-click VM → Properties → Snapshots# Delete old snapshots# From command linevirsh snapshot-list "Ubuntu-VM-Name"virsh snapshot-delete "Ubuntu-VM-Name" "snapshot-name"
~/.cache/gnome-boxes/logs/ - GNOME Boxes specific logs
/var/log/libvirt/qemu/ - QEMU/KVM logs
Most issues can be resolved by ensuring the SPICE tools are properly installed and running. When in doubt, a restart of both the VM and the SPICE services often helps!
Pause: Click pause button while VM is running (saves current state)
Shutdown: Click power button → “Shut Down” (graceful shutdown)
Force Shutdown: Right-click VM → “Force Shutdown” (like pulling power)
Keyboard Shortcuts in VM Window
Ctrl+Alt: Release mouse from VM window
F11: Toggle fullscreen
Ctrl+Alt+F: Toggle fullscreen (alternative)
Ctrl+Alt+Q: Quit VM window (VM keeps running)
Snapshots
Snapshots save the complete VM state at a point in time, perfect for:
Before system updates
Before installing new software
Creating restore points for testing
Creating Snapshots
Right-click VM → Properties
Go to Snapshots tab
Click ”+” button
Name it descriptively:
“Fresh Install - Ubuntu 24.04”
“Before Development Setup”
“Clean State - 2024-01-15”
Managing Snapshots
# From command line (advanced)# List snapshotsvirsh snapshot-list "Ubuntu-VM-Name"# Create snapshotvirsh snapshot-create-as "Ubuntu-VM-Name" "Snapshot-Name" "Description"# Revert to snapshotvirsh snapshot-revert "Ubuntu-VM-Name" "Snapshot-Name"# Delete snapshotvirsh snapshot-delete "Ubuntu-VM-Name" "Snapshot-Name"
Snapshot Best Practices
Take snapshots when VM is shut down for consistency
Delete old snapshots to save disk space
Name snapshots descriptively
Don’t rely on snapshots as backups
Cloning VMs
Cloning creates an exact copy of your VM:
Via GNOME Boxes
Ensure source VM is shut down
Right-click VM → Clone
Enter new name
Wait for cloning to complete
Via Command Line
# Full clone (independent copy)virt-clone --original "Ubuntu-VM" --name "Ubuntu-Clone" --auto-clone# Check the clonevirsh list --all
VM Import/Export
Exporting a VM
# Find VM storage locationvirsh domblklist "Ubuntu-VM"# Export VM definitionvirsh dumpxml "Ubuntu-VM" > ubuntu-vm.xml# Copy disk image (usually in)cp /var/lib/libvirt/images/ubuntu-vm.qcow2 ~/backup/
Importing a VM
# Define VM from XMLvirsh define ubuntu-vm.xml# Copy disk image to correct locationsudo cp ~/backup/ubuntu-vm.qcow2 /var/lib/libvirt/images/# Start the imported VMvirsh start "Ubuntu-VM"
Advanced Features
USB Device Passthrough
To use USB devices in your VM:
Insert USB device into host
In GNOME Boxes, while VM is running:
Click the ”…” menu in VM window
Select “Preferences”
Go to “Devices & Shares”
Toggle on the USB device
Troubleshooting USB
# In VM, check if device is detectedlsusb# If not showing, install utilitiessudo apt install usb-utils# Check permissionssudo usermod -aG plugdev $USER
Network Configuration
Default NAT Network
VM gets IP like 192.168.122.x
Can access internet
Host can’t directly access VM
VM can’t be accessed from network
Viewing Network Info
# In VMip addr showip route show# On hostvirsh net-list --allvirsh net-info default
Port Forwarding (NAT)
# Example: Forward host port 8080 to VM port 80# Edit network configurationvirsh net-edit default# Add inside <network> tags:<forward mode='nat'> <nat> <port start='8080' end='8080'> <to addr='192.168.122.100' port='80'/> </port> </nat></forward># Restart networkvirsh net-destroy defaultvirsh net-start default
Resource Hot-Adding
Some resources can be changed while VM is running:
Add/Remove CPUs
# Check current CPUsvirsh vcpucount "Ubuntu-VM"# Set CPU count (VM must support hotplug)virsh setvcpus "Ubuntu-VM" 4 --live
Memory Ballooning
# Check current memoryvirsh dommemstat "Ubuntu-VM"# Adjust memory (in KB)virsh setmem "Ubuntu-VM" 4194304 --live # 4GB
Disk Management
Expand Virtual Disk
# Check current disk sizeqemu-img info /var/lib/libvirt/images/ubuntu-vm.qcow2# Expand disk (VM must be off)qemu-img resize /var/lib/libvirt/images/ubuntu-vm.qcow2 +10G# In VM, expand partitionsudo growpart /dev/sda 1sudo resize2fs /dev/sda1
Add Additional Disk
In GNOME Boxes: Properties → Add Hardware → Storage
Create new disk image
In VM, format and mount:
# Find new disklsblk# Format (assuming /dev/sdb)sudo mkfs.ext4 /dev/sdb# Mountsudo mkdir /mnt/datasudo mount /dev/sdb /mnt/data# Make permanentecho '/dev/sdb /mnt/data ext4 defaults 0 2' | sudo tee -a /etc/fstab
Backup Strategies
Method 1: Snapshot-Based Backup
# Create snapshotvirsh snapshot-create-as "Ubuntu-VM" backup-$(date +%Y%m%d)# Export snapshotvirsh snapshot-dumpxml "Ubuntu-VM" backup-$(date +%Y%m%d) > backup.xml# Copy disk image while VM runscp /var/lib/libvirt/images/ubuntu-vm.qcow2 ~/backup/
# Set CPU quota (50% of one CPU)virsh schedinfo "Ubuntu-VM" --set vcpu_quota=50000# Set I/O limitsvirsh blkdeviotune "Ubuntu-VM" sda --total-bytes-sec=10485760
These management features give you professional-level control over your Ubuntu VM while keeping the simplicity of GNOME Boxes for day-to-day use.