The Struggle of Managing Virtual Machines on Headless Servers
If you frequently tinker with KVM on Linux, you’re likely familiar with virsh or virt-manager. However, things aren’t always ideal. Using virsh requires memorizing a forest of complex commands, while virt-manager forces you to install a desktop environment (GUI) or configure painfully slow X11 forwarding.
For headless servers, installing dozens of graphical libraries just to launch a virtual machine is a waste of resources. Imagine a VPS with only 1GB of RAM—how much is left for the VM after carrying a heavy GUI package? This is where cockpit-machines comes to the rescue. It brings the entire management interface to your web browser, providing a smooth experience while maximizing resource savings.
I personally run a small lab with Proxmox managing about 12 VMs. However, for standalone nodes or pure Ubuntu VPS instances, I always prefer Cockpit. It only consumes about 20MB – 50MB of RAM, significantly lower than running even a minimal desktop environment.
What is Cockpit-machines?
Cockpit is an open-source project sponsored by Red Hat that enables server administration via a web interface. You can monitor CPU, RAM, read logs, or manage users with just a few clicks. Cockpit-machines is an add-on module that transforms Cockpit into a professional virtual machine manager based on libvirt.
Instead of struggling with XML files, every operation—from creating disks and configuring RAM to managing snapshots—is 100% visualized. The standout feature is the Web-Console (VNC/SPICE). You can install an OS for your VM directly in Chrome or Firefox without needing any additional client software.
How to Install Cockpit-machines
Step 1: Prepare the KVM Foundation
First, the server needs virtualization support. If you have already installed KVM, skip this step. Here are the commands for Ubuntu Server:
# Update the system
sudo apt update && sudo apt upgrade -y
# Check for virtualization support (result > 0 means it's supported)
egrep -c '(vmx|svm)' /proc/cpuinfo
# Install core virtualization packages
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst
Step 2: Install the Cockpit Interface
Cockpit is highly popular and available in official repositories. Installation takes less than 2 minutes.
# Install cockpit and the virtual machine module
sudo apt install -y cockpit cockpit-machines
# Enable and start the service
sudo systemctl enable --now cockpit.socket
Important note: Cockpit runs on port 9090 by default. Remember to open this port on your firewall for remote access:
sudo ufw allow 9090/tcp
Step 3: Access and Experience
Now, open your browser and go to: https://your-server-ip:9090. Don’t worry if you see a security warning (self-signed SSL); just click “Advanced” and proceed. Log in using your system’s sudo account.
In the left menu, the Virtual Machines section will appear. All virtual machines running on the server will be listed here.
Practical Virtual Machine Management
Rapid VM Creation
Click Create VM to start. Simply enter a name, select an ISO file (ideally stored in /var/lib/libvirt/images), and allocate resources. A pro tip from my experience: Always choose QCOW2 as the Storage Type for easy capacity expansion or snapshot creation later.
Configuring Bridge Networking
By default, VMs use NAT, making external access to the VM quite difficult. Cockpit allows you to create a Bridge directly in the Networking tab. This helps the VM receive an IP in the same range as the server’s LAN, which is much more convenient than manually editing the risky /etc/netplan/ file.
Using the Web Console
When you click on a VM, select the Consoles tab. You’ll see the OS installation screen immediately. This feature fully supports mouse and keyboard, making the installation of Windows Server or Linux distros effortless. No more struggling with SSH Tunnels or complex VNC Viewer configurations.
Quick Comparison with Virt-manager
- Pros: Extremely lightweight, manageable from anywhere via Web, built-in host resource monitoring (Disk, Network, Logs).
- Cons: Lacks some advanced settings like PCI Passthrough (for those wanting to pass a GPU to a VM) or detailed CPU Topology adjustments.
Conclusion
Cockpit-machines wasn’t built to compete with giants like Proxmox or vSphere. Its goal is simplicity. It is the top choice for sysadmins managing a few individual servers or developers needing a quick testing environment on a VPS.
With just a 5-minute installation, you have a professional VM management system. If you own a Linux server, try installing Cockpit now to see how virtualization management has never been easier.
