GNOME-Boxes

-

Installing Ubuntu in GNOME Boxes on Pop!_OS (Simplified)

Prerequisites

  • Pop!_OS installed
  • 8GB RAM (4GB minimum)
  • 25GB free disk space
  • Internet connection

Step 1: Install GNOME Boxes

sudo apt update
sudo apt install gnome-boxes

Step 2: Launch GNOME Boxes

Press Super key and search for "Boxes" or type gnome-boxes in terminal

Step 3: Create Ubuntu VM

  1. Click the "+" button or "Create a Virtual Machine"
  2. GNOME Boxes shows available ISOs - select Ubuntu from the list
  3. Choose your Ubuntu version (22.04 LTS or 24.04 LTS recommended)
  4. Click "Next"

Step 4: Configure Resources

  • Memory: 4-8 GB
  • Storage: 25-50 GB
  • Click "Create"

Step 5: Install Ubuntu

  1. Click on your VM to start
  2. Select "Install Ubuntu"
  3. Choose language and keyboard
  4. Select "Erase disk and install Ubuntu" (only affects virtual disk)
  5. Create your user account
  6. Wait for installation (15-30 minutes)
  7. Restart when prompted

Step 6: First Boot

Log in and complete Ubuntu's initial setup. Your VM is ready to use!

Tips:

  • Right-click VM → Properties to adjust CPU cores or enable 3D acceleration
  • GNOME Boxes handles most settings automatically
  • The VM won't affect your Pop!_OS installation

-

Yes, you can SSH into your Ubuntu VM from the Pop!_OS host! Here's how to set it up:

Step 1: Install SSH Server in VM

# In your Ubuntu VM
sudo apt update
sudo apt install openssh-server

# Start and enable SSH service
sudo systemctl enable ssh
sudo systemctl start ssh

# Verify it's running
sudo systemctl status ssh

Step 2: Find the VM's IP Address

# In the Ubuntu VM, get the IP address
ip addr show

# Or use this simpler command
hostname -I

Look for an IP address like 192.168.122.xxx (common for libvirt/GNOME Boxes VMs).

Step 3: SSH from Host

# From your Pop!_OS host
ssh username@vm-ip-address

# Example:
ssh john@192.168.122.45

Alternative: Use VM Name (if mDNS works)

# Try using the VM's hostname
ssh username@ubuntu-vm-name.local

Useful SSH Tips

Set up Key-based Authentication

# From host, copy your public key to VM
ssh-copy-id username@vm-ip-address

# Now you can SSH without password
ssh username@vm-ip-address

Create SSH Alias

Add to ~/.ssh/config on host:

Host myvm
    HostName 192.168.122.45
    User john
    Port 22

Then just use: ssh myvm

Firewall Considerations

Ubuntu's firewall (ufw) is usually inactive by default, but if you have issues:

# In VM, allow SSH
sudo ufw allow ssh
sudo ufw enable

Benefits of SSH Access

  • File transfer with scp or rsync
  • Remote terminal access
  • Port forwarding
  • Running commands without opening VM window
  • Better for development workflows

This gives you much more flexible access to your VM than just the GNOME Boxes console!

-

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

  1. Install GNOME Tweaks: sudo apt install gnome-tweaks
  2. Open Tweaks → Appearance → Animations → OFF
  3. 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

  1. Allocate Enough Resources: Give the VM at least 2 CPUs and 4GB RAM
  2. Keep Host System Light: Close unnecessary applications on Pop!_OS
  3. Regular Updates: Keep both host and guest systems updated
  4. Restart After Optimization: Reboot the VM after applying these changes
  5. 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.

-

Troubleshooting Ubuntu in GNOME Boxes

Common Issues and Solutions

VM Won't Start

Black Screen on Boot

# On the host, check if KVM is loaded
lsmod | grep kvm

# If not loaded, load KVM modules
sudo modprobe kvm
sudo modprobe kvm_intel  # For Intel CPUs
# OR
sudo 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

  1. In GNOME Boxes, right-click VM → Properties
  2. Reduce RAM allocation (might be over-allocated)
  3. Disable 3D acceleration temporarily
  4. Try booting with 1 CPU core first

Display Issues

Resolution Won't Change / Stuck at Low Resolution

# In the VM, reinstall SPICE agent
sudo apt install --reinstall spice-vdagent

# Restart the service
sudo systemctl restart spice-vdagentd

# Force reload the kernel module
sudo modprobe -r vboxvideo  # Remove if exists
sudo modprobe virtio-gpu

# Manually set resolution
xrandr --output Virtual-1 --mode 1920x1080

No 3D Acceleration

# Check if 3D is working
glxinfo | grep "direct rendering"

# If it shows "No", install drivers
sudo apt install mesa-utils libgl1-mesa-glx libgl1-mesa-dri

# Check renderer
glxinfo | grep "OpenGL renderer"
# Should show "llvmpipe" or "virgl" for virtual GPU

Screen Tearing or Flickering

# Disable compositor effects
gsettings set org.gnome.desktop.interface enable-animations false

# Or try a different compositor
sudo apt install compton
compton --backend glx --vsync opengl-swc &

Performance Issues

VM Running Very Slowly

# Check if KVM acceleration is being used
grep -E 'vmx|svm' /proc/cpuinfo  # On host
# If no output, virtualization isn't enabled in BIOS
PP
# In the VM, verify KVM is being used
sudo apt install cpu-checker
kvm-ok
# Should report "KVM acceleration can be used"

# Check CPU governor
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# Set to performance if needed
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

High CPU Usage

# Find what's using CPU
top
# Or for better interface
htop

# 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 usage
free -h

# Clear caches
sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches

# Check for memory leaks
ps aux --sort=-%mem | head -10

Clipboard Not Working

Clipboard Sharing Broken

# Check if spice-vdagent is installed
dpkg -l | grep spice-vdagent

# Reinstall if needed
sudo apt install --reinstall spice-vdagent

# Check if service is running
systemctl status spice-vdagentd

# Start manually if needed
sudo systemctl start spice-vdagentd

# Check for running agent processes
ps aux | grep vdagent
# Should see both spice-vdagentd and spice-vdagent

Copy/Paste Only Works One Direction

# Kill and restart agents
sudo killall spice-vdagent
sudo systemctl restart spice-vdagentd

# Check logs for errors
journalctl -u spice-vdagentd -f

Network Problems

No Internet Connection

# Check network interfaces
ip addr show

# Restart network
sudo systemctl restart NetworkManager

# Check DNS
cat /etc/resolv.conf
# Should have nameserver entries

# Set DNS manually if needed
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf

Slow Network Speed

# Check current network driver
lspci -k | grep -A 3 -i network

# Should be using virtio driver
# If not, the VM might be using e1000 (slower)

# Test network speed
sudo apt install speedtest-cli
speedtest-cli

Shared Folders Not Working

Folder Not Appearing

# Check if spice-webdavd is installed and running
systemctl status spice-webdavd

# Install if missing
sudo apt install spice-webdavd

# Enable and start
sudo systemctl enable spice-webdavd
sudo systemctl start spice-webdavd

# Check for mounts
mount | grep webdav

Permission Denied on Shared Folder

# Check ownership
ls -la /media/

# Add user to necessary group
sudo usermod -aG fuse $USER

# Logout and login again

# If still not working, try manual mount
sudo mkdir /mnt/shared
sudo chmod 777 /mnt/shared

Audio Issues

No Sound in VM

# Check audio devices
pactl list short sinks

# Install PulseAudio volume control
sudo apt install pavucontrol
pavucontrol

# Check if output device is correct

# Restart PulseAudio
pulseaudio -k
pulseaudio --start

Crackling or Distorted Audio

# Edit PulseAudio config
sudo nano /etc/pulse/daemon.conf

# Add or modify:
default-sample-rate = 48000
default-fragments = 4
default-fragment-size-msec = 5

# Restart PulseAudio
pulseaudio -k

Boot Problems

VM Boots to GRUB Prompt

# At grub prompt, manually boot:
grub> set root=(hd0,1)
grub> linux /boot/vmlinuz root=/dev/sda1
grub> initrd /boot/initrd.img
grub> boot

# Once booted, repair GRUB:
sudo update-grub
sudo grub-install /dev/sda

Very Slow Boot Time

# Analyze boot
systemd-analyze blame

# Disable unnecessary services
sudo systemctl disable snapd.service
sudo 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_DEFAULT
sudo update-grub

VM Management Issues

Can't Delete VM

  1. Make sure VM is stopped
  2. Try from command line:
# List VMs
virsh list --all

# Force destroy if running
virsh destroy "Ubuntu-VM-Name"

# Undefine VM
virsh undefine "Ubuntu-VM-Name" --remove-all-storage

Snapshots Not Working

# Check disk space on host
df -h

# Clean up old snapshots in GNOME Boxes
# Right-click VM → Properties → Snapshots
# Delete old snapshots

# From command line
virsh snapshot-list "Ubuntu-VM-Name"
virsh snapshot-delete "Ubuntu-VM-Name" "snapshot-name"

Getting Help

Diagnostic Commands

# Comprehensive system info
sudo apt install inxi
inxi -Fxz

# VM-specific info
virsh dumpxml "VM-Name" | grep -E 'type|machine|os'

# Check GNOME Boxes logs
journalctl -u libvirtd -f

Log Files to Check

  • /var/log/syslog - General system logs
  • ~/.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!

-

VM Management and Advanced Features

Managing Your Ubuntu VM

Basic VM Operations

Starting and Stopping

  • Start: Click on the VM in GNOME Boxes main window
  • 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

  1. Right-click VM → Properties
  2. Go to Snapshots tab
  3. Click "+" button
  4. Name it descriptively:
    • "Fresh Install - Ubuntu 24.04"
    • "Before Development Setup"
    • "Clean State - 2024-01-15"

Managing Snapshots

# From command line (advanced)
# List snapshots
virsh snapshot-list "Ubuntu-VM-Name"

# Create snapshot
virsh snapshot-create-as "Ubuntu-VM-Name" "Snapshot-Name" "Description"

# Revert to snapshot
virsh snapshot-revert "Ubuntu-VM-Name" "Snapshot-Name"

# Delete snapshot
virsh 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

  1. Ensure source VM is shut down
  2. Right-click VM → Clone
  3. Enter new name
  4. Wait for cloning to complete

Via Command Line

# Full clone (independent copy)
virt-clone --original "Ubuntu-VM" --name "Ubuntu-Clone" --auto-clone

# Check the clone
virsh list --all

VM Import/Export

Exporting a VM

# Find VM storage location
virsh domblklist "Ubuntu-VM"

# Export VM definition
virsh 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 XML
virsh define ubuntu-vm.xml

# Copy disk image to correct location
sudo cp ~/backup/ubuntu-vm.qcow2 /var/lib/libvirt/images/

# Start the imported VM
virsh start "Ubuntu-VM"

Advanced Features

USB Device Passthrough

To use USB devices in your VM:

  1. Insert USB device into host
  2. 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 detected
lsusb

# If not showing, install utilities
sudo apt install usb-utils

# Check permissions
sudo 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 VM
ip addr show
ip route show

# On host
virsh net-list --all
virsh net-info default

Port Forwarding (NAT)

# Example: Forward host port 8080 to VM port 80
# Edit network configuration
virsh 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 network
virsh net-destroy default
virsh net-start default

Resource Hot-Adding

Some resources can be changed while VM is running:

Add/Remove CPUs

# Check current CPUs
virsh vcpucount "Ubuntu-VM"

# Set CPU count (VM must support hotplug)
virsh setvcpus "Ubuntu-VM" 4 --live

Memory Ballooning

# Check current memory
virsh dommemstat "Ubuntu-VM"

# Adjust memory (in KB)
virsh setmem "Ubuntu-VM" 4194304 --live  # 4GB

Disk Management

Expand Virtual Disk

# Check current disk size
qemu-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 partition
sudo growpart /dev/sda 1
sudo resize2fs /dev/sda1

Add Additional Disk

  1. In GNOME Boxes: Properties → Add Hardware → Storage
  2. Create new disk image
  3. In VM, format and mount:
# Find new disk
lsblk

# Format (assuming /dev/sdb)
sudo mkfs.ext4 /dev/sdb

# Mount
sudo mkdir /mnt/data
sudo mount /dev/sdb /mnt/data

# Make permanent
echo '/dev/sdb /mnt/data ext4 defaults 0 2' | sudo tee -a /etc/fstab

Backup Strategies

Method 1: Snapshot-Based Backup

# Create snapshot
virsh snapshot-create-as "Ubuntu-VM" backup-$(date +%Y%m%d)

# Export snapshot
virsh snapshot-dumpxml "Ubuntu-VM" backup-$(date +%Y%m%d) > backup.xml

# Copy disk image while VM runs
cp /var/lib/libvirt/images/ubuntu-vm.qcow2 ~/backup/

Method 2: Live Backup with Virsh

# Backup running VM
virsh backup-begin "Ubuntu-VM" backup.xml

# Check backup progress
virsh domjobinfo "Ubuntu-VM"

Method 3: Inside VM Backup

# Use standard Linux backup tools
sudo apt install timeshift
# Or
sudo apt install deja-dup

Performance Monitoring

Host-Side Monitoring

# Monitor VM resource usage
virt-top

# Detailed VM stats
virsh domstats "Ubuntu-VM"

# Real-time performance
virsh dommemstat "Ubuntu-VM" --period 1

Guest-Side Monitoring

# Install monitoring stack
sudo apt install prometheus-node-exporter
sudo apt install netdata

# Access Netdata dashboard
# http://localhost:19999

Automation with Virsh

Create Start/Stop Scripts

#!/bin/bash
# start-vm.sh
virsh start "Ubuntu-VM"
virt-viewer "Ubuntu-VM" &

# stop-vm.sh
virsh shutdown "Ubuntu-VM"

Autostart VM on Boot

# Enable autostart
virsh autostart "Ubuntu-VM"

# Disable autostart
virsh autostart --disable "Ubuntu-VM"

Security Hardening

Enable AppArmor/SELinux for VMs

# Check security driver
virsh capabilities | grep secmodel

# Enable AppArmor profile
sudo aa-enforce /etc/apparmor.d/libvirt/libvirt-*

Limit VM Resources

# Set CPU quota (50% of one CPU)
virsh schedinfo "Ubuntu-VM" --set vcpu_quota=50000

# Set I/O limits
virsh 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.


Children
  1. advanced
  2. installation
  3. optimization
  4. ssh-into-vm
  5. troubleshooting

Backlinks