Day 0: The Training Ground
Goal: A lab VM that can run VMs of its own, an SSH key, and the companion code. · Duration: approx. 30 min · Prerequisite: none
Briefing
- OpenNebula is software for private clouds. It manages hypervisors, storage, and networks and uses them to provide VMs, through a web UI, CLI, or API. In its role it resembles VMware vCenter or OpenStack, but it is much smaller.
- An OpenNebula installation has two parts: the front-end (the control center with database, web UI, and services) and one or more hosts on which the VMs run. In the lab, both are the same machine.
- The VMs run under KVM. Your lab VM is itself already a VM, so you need nested virtualization: the lab VM must see the virtualization features of the CPU.
Laptop ──ssh──► Labor-VM one (Ubuntu 24.04, KVM)
├─ Frontend: oned, Sunstone, OneFlow, OneGate, MariaDB
└─ Host localhost: KVM
├─ VM db (Postgres) 192.168.150.x
└─ VM notes (notes-api) 192.168.150.y
Browser ─► http://<VM-IP>/ Sunstone
Drill 1: The lab VM
You need a VM with Ubuntu 24.04, 2 vCPUs, 4 GB RAM, and a 30 GB disk in which KVM works. That depends on the hypervisor underneath:
| Underneath | What you set |
|---|---|
| Proxmox | CPU type host |
| libvirt/virt-manager | CPU model “host-passthrough” |
| Multipass on Linux | works if the Linux host allows nested virtualization |
| VirtualBox | “Enable Nested VT-x/AMD-V” |
| Mac with Apple Silicon | does not work, use a Linux machine or a server in the cloud |
| Cloud server | provider with nested virtualization or a bare-metal server |
Log in via SSH. From here on, everything runs inside the VM. First, the most important question:
ls -l /dev/kvm
grep -c -E 'vmx|svm' /proc/cpuinfoExpected (date and number will differ):
crw-rw---- 1 root kvm 10, 232 Nov 12 19:00 /dev/kvm
4
/dev/kvmis the interface to KVM. If the file is missing, OpenNebula cannot start any VMs.vmx(Intel) orsvm(AMD) are the CPU features for it.grep -ccounts the lines in/proc/cpuinfothat mention them, usually two per core. The exact number does not matter, what matters is: greater than0. With0, nested virtualization is off.
free -g | head -2
df -h / | tail -1Expected (roughly):
total used free shared buff/cache available
Mem: 3 0 3 0 0 3
/dev/sda1 29G 2.7G 26G 10% /
4 GB is tight, but enough for OpenNebula itself and two small VMs with 256 to 512 MB each.
Save your progress? Sign up for free
Drill 2: The hostname
OpenNebula remembers the host by its name. A clear name helps when reading output:
sudo hostnamectl set-hostname one
hostnameExpected:
one
Save your progress? Sign up for free
Drill 3: An SSH key
The VMs in OpenNebula receive your public key at boot. You then do not need a password:
ssh-keygen -q -t ed25519 -N "" -f ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pubExpected (your key will differ):
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPXPvt6i… ubuntu@one
Save your progress? Sign up for free
Drill 4: The companion code
mkdir -p ~/one-lab
git clone -q https://github.com/thomaszachmann/opennebula-zum-anfassen.git ~/one-lab/code
ls ~/one-lab/code ~/one-lab/code/loesungExpected:
/home/ubuntu/one-lab/code:
LICENSE loesung README.md wettkampf
/home/ubuntu/one-lab/code/loesung:
pruefung tag05 tag07 tag09 tag11 tag13
tag04 tag06 tag08 tag10 tag12 tag14
loesung/tagNN contains the templates and files you write
on each day. You only need wettkampf/ on Day 15.
Save your progress? Sign up for free
Checkpoint
ls /dev/kvmExpected: /dev/kvm.
hostnameExpected: one.
ls ~/.ssh/id_ed25519.pub ~/one-lab/code/README.mdExpected: both files are listed without errors.
Challenge
How many VMs with 256 MB RAM fit into your lab VM on paper if you reserve 1.5 GB for Ubuntu and OpenNebula itself? And why is the real number smaller?
Solution
free -m | awk '/Mem:/ {print int(($2 - 1536) / 256)}'Expected (with 4 GB):
9
Nine on paper. In reality fewer: besides its RAM, each VM needs memory for the QEMU process (usually 50 to 100 MB), and the file cache and database grow along with it. In the lab, three to four concurrent VMs are enough. By the way, OpenNebula does not protect you from overcommitting real memory; it only calculates with what the templates specify (Day 2).
Save your progress? Sign up for free
Enterprise Note
- No nesting in production: In production, OpenNebula hosts run on real hardware. Nested virtualization is slower and is not supported by many vendors.
- Separate front-end and hosts: In production, the front-end lives on its own machines, often three for high availability, and the hosts are pure KVM servers.
- Why OpenNebula? Compared to vCenter, no per-core license costs; compared to OpenStack, far fewer moving parts. Typical use cases are mid-sized private clouds, edge sites, and data centers migrating away from VMware.