XCP-ng: Evolution of Lab V2.0 - OS Installation and VM Deployment for Xen Orchestra
- Installing XCP-ng 8.3 (based on CentOS 7) on the three servers.
- Initial SSH connection to the dom0 and updating of packages.
- Creating a local LVM SR of 150 GB on each server, entirely from the command line.
- Deploying the Rocky Linux VM for Xen Orchestra from the dom0.
Introduction
Now that the previous article has established the target and explained the architecture to be implemented, we can proceed with the installation of the servers.
XCP-ng does not present any specific installation difficulties.
Simply obtain the ISO, then copy it to a USB drive using a utility like Rufus.
The installation process is similar to that of any other Linux OS.
XCP-ng Base
It's important to note that XCP-ng 8.3, which is the latest LTS version as of this article, is based on CentOS 7.0.
Some people might be concerned, knowing that CentOS 7.0 has been "end of life" for quite some time for the general public, but Vates maintains its own repositories and ensures the security of the packages.
This choice guarantees maximum stability for the management tools (XAPI) which have historically been developed for this base.
Dom0 Principle
Furthermore, this CentOS 7.0 foundation does not contain the hypervisor; it runs on top of it. In the world of Xen, the hypervisor that underlies XCP-ng is called Dom0 (short for Domain 0), which is a privileged virtual machine that starts automatically when the server is launched.
Consider it the "brain" or the "control panel" of your server.
This is the VM you access once the XCP-ng installation is complete.
The management API (XAPI) that communicates with the rest of the XCP ecosystem is deployed within this VM.
The core of the Xen hypervisor itself has no shell or possibility of direct access.
All other VMs that can be subsequently deployed will run in so-called DomainU environments, which are non-privileged domains.
The CentOS 7.0 base of Domain0 remains highly customized and adapted by Vates, particularly with a specific kernel. It is possible to install traditional packages on this VM, but it is still recommended not to customize it too much and to keep it as close as possible to its default configuration.
OS Installation
To return to the installation from the ISO, once placed on a USB drive, you simply need to boot the server from it (in my case, on my Lenovo ThinkCenter M920qp mentioned previously). Then, follow the installation wizard.
In short, we set a password and choose the administration IP address. Then, we let the copying of binaries to the local disk proceed.
For the IP address, we use the integrated network card of the Lenovo machines. This will allow us to have a dedicated administration interface, not shared with the 10Gb card reserved for production traffic and storage replication.
However, there is a small subtlety. By default, in addition to the space taken up by the basic installation on the disk (between 40GB and 70GB), the installer will offer to create an SR (Storage Repository), which is equivalent to a datastore in VMware, dedicated to hosting future VMs that will run on the server for which we are performing the installation.
However, in my architecture, I want to set this configuration later, since, as explained in my previous article, I plan to divide the remaining space on my system disks into two parts:
- One part for a local SR
- One part for an SR based on a block replication technology to provide replicated storage between my different servers that make up my XCP-ng pool. We will have the opportunity to see this point in a dedicated article.
Therefore, we will uncheck the automatic creation of the SR during installation.
Click the image to enlarge.
Once finished, you can access the GUI of each server. Indeed, XCP-ng is provided with a minimalist interface called XO-lite, which allows you to view the server and perform initial operations, similar to a free ESXi.
Click the image to enlarge.
Click the image to enlarge.
The account to use is the one you configured during the XCP-ng installation
Except for verifying that everything is OK and that the servers are online, we will mainly act via SSH for the next steps.
To recap, our ultimate goal is not to treat each server individually, but to aggregate them into a pool that we can administer via the Xen Orchestra solution, similar to vCenter for a VMware cluster.
Initial connection and update
We authenticate via SSH on each of the deployed servers (prdxcpsrv001, prdxcpsrv002, prdxcpsrv003), or rather, on each dom0 VM.
From this point onwards, the operations will be identical on each server and therefore need to be repeated on each connection.
First, the immediate action is to update the distribution. Even though the installation has just been completed, packages are frequently updated.
To do this, there's nothing simpler than a yum update followed by a quick reboot for safety.
Click the image to enlarge.
Creating the Local SR (Storage Repository)
Next, the goal is to create a local SR (Storage Repository) on each server with a capacity of 150GB (I remind you that each server has a 1TB SSD, of which approximately 46GB is already used by the XCP-ng installation).
Since we are on a Linux system like CentOS, we can apply the standard methods for managing partitions within this operating system. As Dom0 has specific privileges, it directly accesses the server's hardware, so we can directly manipulate the local disk structure.
We perform a quick lsblk to discover the default partitioning scheme.
Click the image to enlarge.
You can clearly see that there is still free space and that we only have a few basic partitions.
For an NVMe drive, it is referenced as /dev/nvme0n1. You need to adapt this based on your configurations.
We use the fdisk tool to create a new partition that will not take up all available space but will extend over 150GB.
fdisk /dev/nvme0n1
In my case, this is the 4th partition of the disk.
Using fdisk, I will execute the following commands:
n
4
+150G
t
4
8e
W
Click the image to enlarge.
Then we exit fdisk to force a re-reading of the partitions.
partprobe /dev/nvme0n1
Click the image to enlarge.
To stick with the traditional approach, we will proceed with using LVM rather than directly managing the partition.
Therefore, we create a new physical volume (Physical Volume) attached to this new partition.
pvcreate /dev/nvme0n1p4
Click the image to enlarge.
This physical volume will be dedicated to a volume group (Volume Group).
vgcreate VG_Local_PRD /dev/nvme0n1p4
Click the image to enlarge.
Now we are ready to create our local SR, and from this point onwards, we enter the specifics of XCP-ng and Xen.
First, we retrieve the UUID of the server we are on. To do this, we use the command xe host-list
Click the image to enlarge.
Next, we will execute the command xe sr-create configuring it to point to our local storage volume (Local-Storage-PRD) and our unique host identifier (here 503e202a-7ad2-4dbf-a575-ed81df29e89d). We will name it Local-Storage-PRD and define it as an LVM type with the device /dev/nvme0n1p4.
xe sr-create name-label="Local-Storage-PRD" \
type=lvm \
device-config:device=/dev/nvme0n1p4 \
host-uuid=503e202a-7ad2-4dbf-a575-ed81df29e89d \
shared=false
Click the image to enlarge.
We can control the creation of the storage repository using this command
xe sr-list name-label="Local-Storage-PRD"
Click the image to enlarge.
We can obtain information about its size and usage
xe sr-list uuid=7631f311-da3a-80ee-2db0-024e61da871e params=name-label,physical-size,physical-utilisation
Click the image to enlarge.
At this stage, we have three local storage repositories, one per server, all named Local-Storage-PRD and with a capacity of 150GB.
Therefore, we can now mount VMs specific to each node, hosting them on this storage repository.
VM deployment for Xen Orchestra
We will now focus on the first server (prdxcpsrv001), which we will later designate as the master of our XCP-ng pool and which will be responsible for running the VM hosting the Xen Orchestra management solution.
Xen Orchestra can be deployed as an appliance, but in this case, a license is required to access all its functions (this is the preferred method for businesses). Otherwise, it can run directly on a Linux server from the product's source code. In the latter case, no licenses are needed to have 100% of the features, but the installation is more complex and time-consuming, requiring the deployment of a VM.
The base operating system will be Rocky Linux 10, which will run on the first XCP-ng server and will utilize the new local storage repository.
However, in addition to the need for local storage, we also need to be able to mount the Rocky Linux 10 ISO image.
Creating the storage repository for the ISO image
That's why, on this first XCP-ng server, still using SSH, we will create a new storage repository that points to an NFS volume hosted on my NAS (a Terramaster F4) where the Rocky Linux 10 ISO image is located.
We are therefore using the command xe sr-create again, but this time with different arguments and pointing to the IP address of the NAS, indicating the volume to use.
xe sr-create name-label="NFS-ISO-Library" \
type=iso \
device-config:location=192.168.10.152:/Volume1/nfsshare/tools/ISOs \
device-config:nfsversion=3 \
content-type=iso
Click the image to enlarge.
Note that we specify via the content-type option that it will be a storage repository dedicated to ISO images.
Of course, you must ensure that the NFS volume is accessible from the IP address of the XCP-ng server. The configuration will depend on your NFS solution.
I have already placed the Rocky Linux ISO image in the shared folder. For XCP-NG to be able to use it, we first need to force a refresh of the content with this command.
xe sr-scan uuid=$(xe sr-list name-label="NFS-ISO-Library" --minimal)
From there, we can verify that the ISO image is correctly detected.
xe vdi-list sr-uuid=$(xe sr-list name-label="NFS-ISO-Library" --minimal)
Click the image to enlarge.
That's perfect, everything is ready to create our first VM on the first XCP-ng server that we have just deployed.
VM Creation
The command line will continue to be our ally with these instructions
VM_UUID=$(xe vm-install template="Other install media" new-name-label="prdxcpxor501")
Click the image to enlarge.
This first command will create the shell of the VM, which I call prxcpxor501, and store its UUID in the variable VM_UUID
Please note that Rocky Linux 10 is relatively new, so it does not appear in the list of known templates for XCP-ng at the time of writing this article. Therefore, we are using the Other install media template.
In XCP-ng, a template allows you to reconfigure a VM with the correct hardware settings based on the operating system that will be running on it.
To allow it to start, we will configure the use of 2 vCPUs
xe vm-param-set uuid=$VM_UUID VCPUs-max=2
xe vm-param-set uuid=$VM_UUID VCPUs-at-startup=2
Click the image to enlarge.
Regarding RAM, by default, there is a limit of 4GB, which is related to the template. However, if necessary, we can use the command.
xe vm-memory-limits-set uuid=$VM_UUID \
static-min=4GiB \
static-max=4GiB \
dynamic-min=4GiB \
dynamic-max=4GiB
Click the image to enlarge.
In XCP-ng, managing RAM is slightly more complex than just specifying a number because it allows for "dynamic memory" (Dynamic Memory Control). Here's what the above command modifies:
- Static MAX: The absolute physical limit (the VM will never see more than this).
- Dynamic MAX: The upper limit that the VM can reach without a restart.
- Dynamic MIN: The minimum amount that the VM can accept to release if the host is running low on RAM.
- Static MIN: The survival threshold below which the VM cannot start.
By default, if you are not using dynamic memory, it is recommended to set these four values to the same size (as in the example).
We can list the VM to see if it is correctly configured
xe vm-list name-label="prdxcpxor501"
Creating the virtual disk
Now we will configure the disk.
We are creating a virtual volume of 30GB
VDI_UUID=$(xe vdi-create sr-uuid=68fd19d4-ed9d-168f-c178-f6824246043e name-label="prdxcpxor501-boot-disk" type=system virtual-size=30GiB)
Click the image to enlarge.
Note that the sr-uuid option points to the UUID of the local sr created previously, which is associated with the server and labeled Local-Storage-PRD. If you need to find it, you can use the command xe xr-list name-label="Local-Storage-PRD"
Since we are retrieving the UUID of the created disk, we can attach it to the VM using the following command
xe vbd-create vm-uuid=$VM_UUID vdi-uuid=$VDI_UUID device=0 bootable=true type=Disk
Click the image to enlarge.
Creating the virtual network interface
Now it's time for the network configuration.
Since this will be the XenOrchestra administration VM and at this stage, we have not configured any other networks besides the one provided by the server's integrated Ethernet card, we will start by retrieving the UUID of this default network.
NET_UUID=$(xe network-list name-label="Pool-wide network associated with eth0" --minimal)
Click the image to enlarge.
Next, we create a virtual interface linked to this network (a vif) that we will map to our VM.
xe vif-create vm-uuid=$VM_UUID network-uuid=$NET_UUID device=0
Click the image to enlarge.
ISO Mapping
We will also mount the Rocky Linux ISO image.
To do this, we retrieve the UUID of the ISO image using the command
xe vdi-list sr-uuid=$(xe sr-list name-label="NFS-ISO-Library" --minimal)
We identify the UUID and use the following command
xe vbd-create vm-uuid=$VM_UUID \
vdi-uuid=889a665e-f230-4235-b994-de243e1f6b06 \
device=3 \
bootable=false \
mode=RO \
type=CD
Boot Configuration
Finally, we will set the boot order using the commands
xe vm-param-set uuid=$VM_UUID HVM-boot-policy="BIOS order"
xe vm-param-set uuid=$VM_UUID HVM-boot-params:order=dc
Click the image to enlarge.
HVM: means Hardware Virtual Machine. This is the full virtualization mode (used for Windows or modern Linux distributions).
In the first command, we tell Xen to use a standard BIOS behavior for this VM.
In the second one, we set the boot order to:
- d: for the CD-ROM drive, which is the ISO image
- c: for the disk.
It's time to start the VM with these instructions
xe vm-start uuid=$VM_UUID
Click the image to enlarge.
Installing Rocky Linux
From this step onwards, we can use the integrated GUI of the first server (XO Lite).
This will allow us to access the VM console and therefore proceed with the installation of Rocky Linux 10
Click the image to enlarge.
I won't go into detail here; we'll follow a standard Linux deployment process with the usual options.
I simply set an IP address on my LAN for SSH access to the VM later, and create my user account.
Final installation steps
Once the installation is complete and the VM has rebooted.
We can return to the XCP-ng shell and then eject the ISO image
xe vm-list name-label=prdxcpxor501 --minimal
VM_UUID=$(xe vm-list name-label=prdxcpxor501 --minimal)
VBD_CD_UUID=$(xe vbd-list vm-uuid=$VM_UUID type=CD --minimal)
xe vbd-eject uuid=$VBD_CD_UUID
We can also take this opportunity to remove the CD-ROM from the boot options
xe vm-param-set uuid=$VM_UUID HVM-boot-params:order=c
Click the image to enlarge.
There are a few more tasks to complete.
To do this, we need to connect via SSH to the newly deployed VM.
As usual, we will run an initial update of the packages using the command dnf update.
Click the image to enlarge.
Then, we install the xe-guest-utilities, which are similar to VMware Tools but for Xen.
This will allow the hypervisor to retrieve information about the VM and display it in the various administration consoles.
There are several ways to do this, but one of the most direct is to install the RPM package directly available in Fedora (the same family of operating systems as Rocky Linux). Be sure to note the version compatible with your system (cat /etc/redhat-release).
At the time of writing this article, there may not be a version available for Rocky Linux 10.1 that was just deployed, but version 10.2 from the Fedora repository works very well.
sudo dnf install https://dl.fedoraproject.org/pub/epel/10.2/Everything/x86_64/Packages/x/xe-guest-utilities-latest-8.4.0-8.el10_2.x86_64.rpm
sudo systemctl enable --now xe-linux-distribution
sudo systemctl status xe-linux-distribution
Click the image to enlarge.
Click the image to enlarge.
Conclusion
This is the end of this second part describing the installation of my Lab V2.0 under XCP-ng.
At this stage, I can access my VM prdxcpxor501 via SSH
This VM was created entirely from the command line using the Dom0 VM available on my first XCP-ng server.
Of course, the idea is not to build all future VMs in this way.
With prdxcpxor501 functional, I can now install the centralized administration solution Xen Orchestra to allow me to create my XCP pool with my three servers and move into a much more practical use of VM creation.
But for that, you need to follow the next article.