
Transform Ubuntu 24.04 into a Powerful KVM Hypervisor with Web Management
Virtualization is a game-changer, letting you run multiple operating systems on one machine. Perfect for testing, hosting, or DevOps adventures. This guide demonstrates how to set up a KVM hypervisor.
Want to transform Ubuntu 24.04 into a robust hypervisor? This guide bypasses Proxmox's complexities, utilizing KVM for rapid VM deployment and Cockpit for easy browser-based control.
What You'll Accomplish
In this tutorial, you’ll convert an Ubuntu 24.04 or Kubuntu 24.04 system into a KVM hypervisor. You'll configure KVM, QEMU, and libvirt, integrate Cockpit for web-based VM management, and deploy a guest VM for testing.
What You Should Know Before Starting
This guide welcomes virtualization beginners and guides you through the process of turning Ubuntu 24.04 into a KVM hypervisor. You'll need some basic skills:
- Executing terminal commands (e.g.,
sudo apt install
,nano
). - Navigating Linux filesystems (e.g., editing files in
/etc
). - Basic networking concepts: network interfaces (e.g.,
enp4s0
,wlp3s0
), IP addresses, bridging, and NAT. You'll use tools likeip link
ornmcli
.
Don't worry if terms like "libvirt" sound unfamiliar. We'll explain everything step-by-step.
What You'll Need
- A computer: Running Ubuntu 24.04 or Kubuntu 24.04. Minimum: 4GB RAM, 20GB storage, CPU with virtualization support (Intel VT-x or AMD-V). The more RAM and storage, the better you can run multiple VMs.
- Internet access: For downloading packages and VM ISOs.
- A web browser: Firefox or Chrome for Cockpit access.
- An ISO image: For your guest VM (e.g., Ubuntu 24.04 Desktop ISO or a Windows ISO).
- Time: Allocate 30–45 minutes, depending on your setup speed.
Why Choose KVM on Ubuntu 24.04?
KVM transforms your Linux kernel into a hypervisor, enabling near-native VM performance. Paired with QEMU and libvirt, it's a streamlined alternative to Proxmox or VMware.
- Performance: Efficient VM execution, perfect for homelabs or dev environments.
- Cost-Effective: Like Ubuntu, KVM is completely free.
- Compatibility: Supports various guest OSs (Linux, Windows, BSD).
- Simplified Management: Cockpit's web UI streamlines VM management, no CLI required.
Understanding the Key Components
- KVM: A Linux kernel module turning your system into a hypervisor, enabling near-native VM performance using CPU virtualization features like Intel VT-x.
- QEMU: Provides virtual hardware (CPU, disk, network) for your VMs, working with KVM for fast execution.
- libvirt: Simplifies VM creation, networking, and storage, offering tools like
virsh
and APIs for automation. - Cockpit: A web-based interface for managing VMs, system resources, and networks.
Ubuntu 24.04 offers excellent KVM compatibility. Let’s turn your system into a KVM hypervisor!
Step 1: Verify Virtualization Support
Check if your CPU supports virtualization. Open a terminal and run:
Look for "VT-x" (Intel) or "AMD-V" (AMD). If present, you're all set! If nothing shows, check your BIOS/UEFI:
- Reboot and enter BIOS (usually F2, Del, or Esc).
- Enable "Intel VT-x" or "AMD-V" under CPU settings.
- Save and reboot.
Step 2: Install KVM and Backend Tools
Install KVM, QEMU, and libvirt, the foundation of your KVM hypervisor:
Update your system:
Then install the packages:
qemu-kvm
: Emulates hardware for VMs.libvirt-daemon-system
: Manages VMs.libvirt-clients
: CLI tools likevirsh
for management.bridge-utils
: Facilitates network bridging.
Verify KVM is loaded:
You should see "kvm_intel" or "kvm_amd".
Add your user to the libvirt group:
Log out and back in to apply changes.
Step 3: Set Up a Network Bridge
VMs need network access, so create a bridge (br0
) to connect them to your physical network.
Note: libvirt creates a default bridge called virbr0
for NAT-based networking (IPs like 192.168.122.x). For direct network access (IPs like 192.168.0.x), use br0
.
Option 1: NetworkManager (Recommended for Kubuntu/Ubuntu Desktop)
-
Check your network interface:
Example:
enp4s0
. Replaceenp4s0
if yours is different. -
Find your Ethernet connection name:
Look for the
NAME
column whereDEVICE
isenp4s0
. Note this name. -
Create a bridge named
br0
: -
Enslave your interface to the bridge:
-
Disable the old connection:
Replace
"Wired connection 1"
with your connection name. -
Enable DHCP on the bridge:
-
Activate the bridge:
-
Verify:
Ensure
br0
is active,enp4s0
is enslaved, andvirbr0
is separate. Test internet withping 8.8.8.8
. -
Define
br0
in libvirt:Create
br0.xml
in your home directory:Add the following:
Save and exit.
-
Define and start the network:
-
Verify network list:
You can now delete ~/br0.xml
.
Option 2: Netplan (For Ubuntu Server or If Preferred)
-
Check your interface:
Example:
enp4s0
. -
Edit the Netplan config:
Use the following:
Save and exit.
-
Set strict permissions:
-
Apply:
-
Verify:
Test the internet with
ping 8.8.8.8
.
Step 4: Install Cockpit for Web Management
Cockpit provides a web UI to manage VMs.
Install Cockpit and its VM plugin:
Start and enable Cockpit:
Open your browser and visit:
https://localhost:9090
Or use your server’s IP (e.g., https://192.168.0.100:9090
) if remote. Log in with your username and password and ignore the self-signed certificate warning.
Allow Cockpit’s port if using a firewall:
You’ll see Cockpit’s dashboard. Turn on administrative access, then click "Virtual Machines."
Step 5: Create a Guest VM using Cockpit
Download the Ubuntu 24.04 Desktop ISO from ubuntu.com.
In Cockpit, go to "Virtual Machines" and click "Create VM". Here are the specifications needed:
- Name: TestVM
- Installation Source: Browse to your ISO.
- OS: Select "Ubuntu 24.04".
- Storage: Create new qcow2 volume (preferred).
- Storage limit: 20GB (adjust as needed).
- Memory: 4GB (adjust as needed).
Click "Create and Edit". In the advanced dialog, ensure br0
is selected as the network interface source. Finally, click "Install".
Step 6: Run and Test the Guest VM
Your VM is running! Let’s test it:
In Cockpit, under "Virtual Machines," click TestVM to see its console.
Log into the guest Ubuntu using your credentials.
Test networking:
Open a terminal in the VM via Cockpit's console.
Run ip addr
to confirm a physical network IP (e.g., 192.168.0.x with br0
).
Run ping 8.8.8.8
to confirm internet access.
If the VM boots and connects to your network, your KVM hypervisor is working!
Keep Exploring Your Hypervisor
Try these next steps:
- Add More VMs: Create Windows or other Linux VMs using different ISOs.
- Use virt-manager: Install
virt-manager
(desktop-based alternative to Cockpit). - Back Up VMs: Export VM disks with
virsh
for safety. - Scale Up: Add storage or RAM for heavier workloads.
Wrapping Up
You’ve built a fast KVM hypervisor on Ubuntu 24.04, complete with Cockpit’s web UI and a running guest VM—a perfect platform for learning, testing, and homelab experimentation.