Practical 2: Implementing VMs on Xen Server
Aim
Install the Xen-based platform used in this practical, XCP-ng. Connect the management client and add storage. Create and manage VMs (Virtual Machines) using the graphical interface and the xe commands.
Theory
Xen is a Type-1 hypervisor. It runs directly on the hardware and shares resources between virtual machines. XCP-ng is a server virtualization platform built around Xen.
A graphical user interface (GUI) uses windows, menus and buttons. A command-line interface (CLI) lets you do tasks by typing commands.
Xen architecture
flowchart TB
subgraph D0[Dom0 – control domain]
T[Toolstack: xapi / xl<br/>xe CLI]
DR[Real device drivers<br/>backend drivers]
end
subgraph DU1[DomU – guest VM 1<br/>PV/PVH]
F1[Frontend drivers]
end
subgraph DU2[DomU – guest VM 2<br/>HVM]
F2[PV drivers / emulated devices]
end
D0 & DU1 & DU2 --> XH[Xen hypervisor – CPU scheduling, memory]
XH --> HW[Hardware]
F1 -. split drivers .-> DR
F2 -. split drivers .-> DR
| Term | Meaning |
|---|---|
| Xen hypervisor | A thin layer that schedules CPUs (Central Processing Units) and manages memory; it has no device drivers itself |
| Dom0 (Domain 0) | A privileged Linux control VM that starts first; it holds the real hardware drivers and the toolstack (xapi, xe, xl) |
| DomU | Ordinary (unprivileged) guest domains – your VMs |
| Split driver model | Guests use frontend drivers that pass disk/network requests to backend drivers in Dom0 through shared memory rings |
The Xen hypervisor is the principal – decides who gets which classroom and time, but does not teach. Dom0 is the school office – it has the keys to the printer, phone and gate (real drivers). DomU VMs are the classrooms. When a classroom needs a printout, it sends a note (frontend driver) to the office, and the office uses the printer (backend driver) – this is the split driver model.
Virtualisation modes in Xen
| Mode | Description |
|---|---|
| PV (Paravirtualization) – paravirtualisation | The guest kernel is modified to make hypercalls instead of privileged instructions; no VT-x needed; very efficient I/O |
| HVM – hardware virtual machine | Uses Intel VT-x (Virtualization Technology for x86) / AMD-V (AMD Virtualization); runs unmodified OSes such as Windows; QEMU (Quick Emulator) imitates devices; install PV drivers for speed |
| PVH | A mix – hardware virtualisation for CPU/memory, PV for I/O, no device imitation; the modern default for Linux |
XenServer, XCP-ng and tools
| Product | Notes |
|---|---|
| Citrix XenServer / Citrix Hypervisor | Commercial Xen platform |
| XCP-ng | Free, open-source fork of XenServer – used in this practical |
| XCP-ng Center / XenCenter | Windows desktop management program |
| Xen Orchestra (XO) | Web-based management for XCP-ng/XenServer pools |
| xe CLI | Command-line tool that talks to the XAPI toolstack |
Key objects:
| Object | Meaning |
|---|---|
| Pool | A group of hosts managed together |
| Host | One physical server |
| SR – storage repository | Where disks are kept (local LVM (Logical Volume Manager)/EXT, NFS (Network File System), iSCSI, ISO library) |
| VDI (virtual disk image) | One virtual disk |
| VBD (Virtual Block Device) | The "cable" connecting a VDI to a VM |
| Network / VIF (Virtual Interface) | A virtual network / a VM's virtual network card |
| Template / Snapshot | A ready-made VM pattern / a save point |
A snapshot or checkpoint depends on the VM disks. It is not an independent backup.
Requirements
- 64-bit CPU with Intel VT-x / AMD-V (for HVM guests), 4 GB+ RAM (Random Access Memory) (8 GB recommended), 60 GB+ disk.
- XCP-ng 8.3 ISO; a Windows client with XCP-ng Center (or a browser for Xen Orchestra Lite).
- A guest OS (Operating System) ISO (Ubuntu / Debian / Windows).
- For a lab, XCP-ng can run nested inside VMware Workstation with Virtualize VT-x/EPT (Extended Page Tables) switched on.
Procedure
Part A – Install XCP-ng (Xen Server)
- Boot the server/VM from the XCP-ng ISO; at the
boot:prompt press Enter. - Select the keymap (
[qwerty] us) → OK. - Accept the EULA (End User License Agreement).
- Choose the installation disk (and select it for local storage; tick Enable thin provisioning for an EXT local SR).
- Installation source: Local media; skip supplemental packs; optionally check the media.
- Set the root password (for example
Vlp@Xen2026). - Networking: select the management network card → Static configuration: IP (Internet Protocol)
192.168.56.30, netmask255.255.255.0, gateway192.168.56.1. - Hostname
xen01, DNS (Domain Name System)8.8.8.8; choose the time zone and NTP (Network Time Protocol). - Confirm Install XCP-ng. When it finishes, remove the media and reboot.
- The host screen (xsconsole) shows the management IP and status.
Part B – Connect a management client
- On Windows install XCP-ng Center, click Add a server → Server
192.168.56.30, userroot, password → Add. - The host
xen01appears in the tree with tabs: General, Memory, Storage, Networking, NICs (Network Interface Cards), Console, Performance, Logs.
(Or open https://192.168.56.30 for Xen Orchestra Lite in the browser.)
Part C – Create an ISO storage repository
This is the "shelf" where installation discs (ISOs) are kept.
- In XCP-ng Center → New Storage → type Windows File Sharing (SMB/CIFS) or NFS ISO.
- Name it
ISO library, enter the share path (for example\\192.168.56.1\iso) → Finish.
Alternative (CLI): copy ISOs to /var/opt/xen/iso on the host and create a local ISO SR:
mkdir -p /var/opt/xen/iso
xe sr-create name-label="Local ISO" type=iso device-config:location=/var/opt/xen/iso \
device-config:legacy_mode=true content-type=iso
xe sr-list content-type=iso
Make the folder → register it as an ISO SR called "Local ISO" → list ISO SRs to confirm.
Part D – Create a VM (New VM wizard)
- Right-click the host → New VM.
- Template: Ubuntu Focal/Jammy Jellyfish 64-bit (or Other install media).
- Name:
ubuntu-xen01; description optional. - Installation media: Install from ISO library or DVD drive → choose the Ubuntu ISO.
- Home server:
xen01. - CPU & Memory: 2 vCPUs, 2 GB RAM.
- Storage: add a 20 GB virtual disk on Local storage.
- Networking: one VIF on Pool-wide network associated with eth0.
- Finish – tick Start the new VM automatically.
- Open the Console tab and install Ubuntu.
- Install the guest tools: mount guest-tools.iso and run
sudo ./install.sh(gives memory/IP reporting and clean shutdown).
Part E – Manage VMs
- Snapshot: right-click the VM → Take a Snapshot →
before-update. - Try Shut down / Reboot / Suspend / Force shutdown from the toolbar.
- Clone a VM or Convert to template to create new VMs quickly.
- View the Performance graphs (CPU, memory, disk, network).
Part F – Manage Xen with the xe CLI
xe host-list # host UUID and name
xe vm-list # all VMs incl. control domain
xe template-list | grep -i ubuntu # available templates
xe vm-install template="Ubuntu Jammy Jellyfish 22.04" new-name-label=cli-vm01 \
sr-uuid=$(xe sr-list name-label="Local storage" --minimal)
xe vm-cd-add vm=cli-vm01 cd-name=ubuntu-22.04-live-server-amd64.iso device=3
xe vif-create vm-uuid=$(xe vm-list name-label=cli-vm01 --minimal) \
network-uuid=$(xe network-list bridge=xenbr0 --minimal) device=0
xe vm-memory-limits-set vm=cli-vm01 static-min=1GiB dynamic-min=1GiB dynamic-max=2GiB static-max=2GiB
xe vm-param-set uuid=$(xe vm-list name-label=cli-vm01 --minimal) VCPUs-max=2 VCPUs-at-startup=2
xe vm-start vm=cli-vm01
xe vm-list name-label=cli-vm01 params=power-state
xe vm-snapshot vm=cli-vm01 new-name-label=snap1
xe vm-shutdown vm=cli-vm01
xe vm-uninstall vm=cli-vm01 force=true # delete VM and disks
What the commands do:
- List the host, the VMs and the Ubuntu templates.
vm-install– createcli-vm01from the Ubuntu template on Local storage.vm-cd-add– put the Ubuntu ISO in its CD drive.vif-create– give it a network card on bridgexenbr0.vm-memory-limits-set/vm-param-set– give it 1–2 GB RAM and 2 vCPUs.vm-start→ checkpower-state→vm-snapshot→vm-shutdown.vm-uninstall– delete the VM and its disks.
The low-level xl toolstack (used by plain Xen on Debian/Ubuntu) offers xl list, xl create vm.cfg, xl console, xl shutdown.
Virtual lab · Xen / XCP-ng · 45 min
Install XCP-ng (Xen) and manage VMs with XCP-ng Center and the xe CLI
Install the XCP-ng 8.3 Xen hypervisor with a static management IP, connect XCP-ng Center from an admin PC, attach an NFS ISO library, create and install an Ubuntu VM, add the guest agent and snapshot it, then build a second VM entirely with the xe CLI.
Output / Observations
Example output for the settings in this lesson:
[root@xen01 ~]# xe vm-list
uuid ( RO) : 3f1c…
name-label ( RW): ubuntu-xen01
power-state ( RO): running
uuid ( RO) : 0b9e…
name-label ( RW): Control domain on host: xen01
power-state ( RO): running
- XCP-ng Center shows
ubuntu-xen01running onxen01with 2 vCPUs, 2 GB RAM and a 20 GB disk on Local storage. - The Control domain (Dom0) is listed as a VM – it is the privileged domain that runs the toolstack and drivers.
Conclusion
Check that the management client can reach the server. Create a VM, start it and check its state. Take a snapshot and use xe to list the VM and its settings.
Viva questions
- What is Xen? Who developed it? An open-source Type-1 hypervisor from the University of Cambridge (2003).
- What are Dom0 and DomU? Dom0 is the privileged control VM with drivers and tools; DomU are the ordinary guest VMs.
- Explain paravirtualisation. How is it different from HVM? PV guests are modified to call the hypervisor with hypercalls; HVM runs unmodified guests using VT-x/AMD-V.
- What is the split driver model in Xen? Frontend drivers in guests send I/O to backend drivers in Dom0 through shared memory.
- What is a storage repository (SR)? Name its types. A place to keep virtual disks/ISOs – local LVM/EXT, NFS, iSCSI, ISO library.
- Differentiate VDI and VBD; VIF and network. VDI is the disk, VBD connects it to a VM; VIF is the VM's NIC, the network is what it plugs into.
- What is XAPI and the xe CLI? XAPI is the management toolstack;
xeis its command-line client. - What is XCP-ng and how is it related to Citrix XenServer? A free open-source fork of XenServer.
- What is PVH mode? Hardware virtualisation for CPU/memory with PV I/O and no device emulation.
- Which public cloud originally ran on Xen? Amazon EC2 (Elastic Compute Cloud).
Practise this topic
Hands-on virtual lab
Apply what you just read in a realistic, guided simulation. Free with a verified account.
Create a free account to track your progress and unlock virtual labs.