optimization
Optimizing Ubuntu VM in GNOME Boxes
Understanding the Integration Tools
Before optimizing, let's understand what each tool does:
SPICE Guest Tools Explained
spice-vdagent (Video Display Agent):
- Purpose: Enables dynamic display resolution, clipboard sharing, and smooth mouse integration
- How it works: Runs as a service in the guest OS, communicating with the host through SPICE protocol
- Benefits:
- Automatic resolution adjustment when resizing VM window
- Seamless mouse movement (no capture/release needed)
- Copy/paste between host and guest
- Drag-and-drop file transfers
spice-webdavd (WebDAV Daemon):
- Purpose: Enables folder sharing between host and guest
- How it works: Creates a WebDAV server for file sharing over SPICE channel
- Benefits: Access host folders from within the VM
qemu-guest-agent:
- Purpose: Provides host-guest communication for VM management
- How it works: Allows the host to query guest information and perform operations
- Benefits:
- Proper VM shutdown/reboot from host
- Guest system information visibility
- Time synchronization
Step 1: Install Essential Guest Tools
Open a terminal in your Ubuntu VM and run:
# Update package list
sudo apt update
# Install SPICE guest tools
sudo apt install spice-vdagent spice-webdavd
# Install QEMU guest agent
sudo apt install qemu-guest-agent
# Install build essentials for potential driver compilation
sudo apt install build-essential dkms
Step 2: Enable and Start Services
# Enable SPICE VDAgent service
sudo systemctl enable spice-vdagentd
sudo systemctl start spice-vdagentd
# Enable QEMU guest agent
sudo systemctl enable qemu-guest-agent
sudo systemctl start qemu-guest-agent
# Verify services are running
systemctl status spice-vdagentd
systemctl status qemu-guest-agent
Step 3: Graphics and Display Optimization
Install Graphics Drivers
# Install Mesa utilities for 3D acceleration
sudo apt install mesa-utils
# Install video acceleration libraries
sudo apt install va-driver-all vdpau-driver-all
# Verify 3D acceleration is working
glxinfo | grep "direct rendering"
# Should output: "direct rendering: Yes"
# Check OpenGL version
glxinfo | 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 utilities
sudo apt install cpufrequtils
# Check current governor
cpufreq-info | grep "governor"
# Set to performance mode (temporary)
sudo cpufreq-set -g performance
# Make performance mode permanent
echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils
sudo systemctl restart cpufrequtils
Reduce Swappiness
# Check current swappiness
cat /proc/sys/vm/swappiness
# Reduce swappiness (default is 60, reduce to 10)
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
# Apply immediately
sudo sysctl vm.swappiness=10
Enable TRIM for Virtual Disk
# Enable periodic TRIM (helps with disk performance)
sudo systemctl enable fstrim.timer
sudo systemctl start fstrim.timer
# Verify it's scheduled
systemctl status fstrim.timer
Step 5: Memory Optimization
Configure zRAM (Compressed RAM)
# Install zRAM tools
sudo apt install zram-tools
# Configure zRAM (creates compressed swap in RAM)
echo -e "ALGO=lz4\nPERCENT=50" | sudo tee /etc/default/zramswap
sudo service zramswap restart
Step 6: Ubuntu-Specific Optimizations
Disable Unnecessary Services
# Disable printer service if not needed
sudo systemctl disable cups
sudo systemctl stop cups
# Disable Bluetooth if not needed
sudo systemctl disable bluetooth
sudo systemctl stop bluetooth
Reduce Visual Effects
- Install GNOME Tweaks:
sudo apt install gnome-tweaks
- Open Tweaks → Appearance → Animations → OFF
- Settings → Accessibility → Reduce Animation → ON
Disable Search Indexing (if not needed)
# Disable file indexing for better performance
sudo systemctl mask tracker-store.service tracker-miner-fs.service
sudo systemctl mask tracker-extract.service tracker-miner-apps.service
sudo systemctl mask tracker-writeback.service
Step 7: Boot Optimization
Configure GRUB for Faster Boot
# Edit GRUB configuration
sudo nano /etc/default/grub
# Change these lines:
GRUB_TIMEOUT=2
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
# Update GRUB
sudo update-grub
Performance Verification
Check Resource Usage
# Monitor system resources
htop # Install with: sudo apt install htop
# Check disk I/O
iotop # Install with: sudo apt install iotop
# Monitor GPU/3D acceleration
glxgears # Should show smooth animation
Benchmark (Optional)
# Install benchmark tools
sudo apt install hardinfo sysbench
# Run simple CPU benchmark
sysbench cpu --cpu-max-prime=20000 run
# Run memory benchmark
sysbench 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
Quick Performance Check Script
Create a script to verify all optimizations:
#!/bin/bash
echo "=== Ubuntu VM Optimization Check ==="
echo "3D Acceleration: $(glxinfo | grep "direct rendering")"
echo "SPICE Agent: $(systemctl is-active spice-vdagentd)"
echo "QEMU Agent: $(systemctl is-active qemu-guest-agent)"
echo "CPU Governor: $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)"
echo "Swappiness: $(cat /proc/sys/vm/swappiness)"
echo "TRIM Timer: $(systemctl is-active fstrim.timer)"
echo "==================================="
Save as check-vm-optimization.sh
, make executable with chmod +x
, and run to verify all optimizations are active.
Backlinks