### XCP-ng Answer File Example (XML)
Source: https://docs.xcp-ng.org/installation/install-xcp-ng
An example of an XML answer file used for unattended XCP-ng installations. This file contains answers to questions the installer would normally ask, such as disk configuration, root password, and network settings.
```xml
sdasdbsdcusmypasswordhttp://pxehost.example.com/xcp-ng/
http://pxehost.example.com/myscripts/post-install-script
Europe/Paris
```
--------------------------------
### Encryption Setup
Source: https://docs.xcp-ng.org/networking
Instructions for installing and enabling the `openvswitch-ipsec` package to enable network encryption on XCP-NG hosts.
```APIDOC
## Encryption Setup
### Description
This section provides the necessary steps to install and configure the `openvswitch-ipsec` package for enabling network encryption on XCP-NG hosts.
### Requirements
- `openvswitch-ipsec` package installed on all hosts.
### Installation and Configuration Steps
1. **Install the package:**
```bash
yum install openvswitch-ipsec --enablerepo=xcp-ng-testing
```
2. **Enable and start services:**
```bash
systemctl enable ipsec
systemctl enable openvswitch-ipsec
systemctl start ipsec
systemctl start openvswitch-ipsec
```
### Further Information
More details on encryption and SDN controller configuration can be found in the official Xen Orchestra documentation.
```
--------------------------------
### Install Koji Client on Ubuntu
Source: https://docs.xcp-ng.org/project/development-process/koji-initial-setup
Installs the Koji client and its dependencies on Ubuntu 24.04+ using pipx. Requires build essentials, Python development headers, Kerberos libraries, and SSL/TLS libraries.
```bash
# Install dependencies
sudo apt install -y build-essential python3-dev libkrb5-dev krb5-user libssl-dev libffi-dev python3-requests-gssapi
# Install koji
pipx install koji
```
--------------------------------
### Install and Enable Open vSwitch IPsec on XCP-ng
Source: https://docs.xcp-ng.org/networking
Installs the openvswitch-ipsec package, enables, and starts the associated system services for network encryption on XCP-ng hosts. Requires the xcp-ng-testing repository.
```bash
yum install openvswitch-ipsec --enablerepo=xcp-ng-testing
systemctl enable ipsec
systemctl enable openvswitch-ipsec
systemctl start ipsec
systemctl start openvswitch-ipsec
```
--------------------------------
### Install pfSense/OPNsense Guest Utilities via CLI
Source: https://docs.xcp-ng.org/guides/pfsense
Installs and enables the necessary Xen guest utilities on pfSense or OPNsense VMs using the command line. This ensures proper integration with the hypervisor and enables features like graceful shutdown and statistics reporting. It involves installing the package, configuring it to run on boot, and starting the service.
```freebsd
pkg install xe-guest-utilities
echo 'xenguest_enable="YES"' >> /etc/rc.conf.local
ln -s /usr/local/etc/rc.d/xenguest /usr/local/etc/rc.d/xenguest.sh
service xenguest start
```
--------------------------------
### Example Kernel Module Paths in XCP-ng
Source: https://docs.xcp-ng.org/project/development-process/kernel-module-policy
Illustrates the typical installation locations for different types of kernel modules on an XCP-ng system, including built-in, updates, and override modules. This helps in understanding module precedence and location.
```text
/usr/lib/modules/4.4.0+10/kernel/drivers/net/ethernet/broadcom/bnxt/bnxt_en.ko
/usr/lib/modules/4.4.0+10/updates/bnxt_en.ko
/usr/lib/modules/4.4.0+10/override/bnxt_en.ko
```
--------------------------------
### Install insserv-compat on openSUSE Leap
Source: https://docs.xcp-ng.org/vms
Installs the 'insserv-compat' package required for the xe-daemon to start on openSUSE Leap 15.2 with transactional-update. This is a prerequisite for installing guest tools in specific cases.
```shell
sudo transactional-uptdate pkg install insserv-compat
```
--------------------------------
### Install Xen Guest Tools on FreeBSD
Source: https://docs.xcp-ng.org/vms
Manually installs 'xen-guest-tools' and 'xe-guest-utilities' packages on FreeBSD and starts the xenguest service. The install.sh script from the ISO is not supported on FreeBSD.
```shell
pkg install xen-guest-tools xe-guest-utilities
service xenguest start
```
--------------------------------
### XCP-ng Answer File Example for Unattended Installation
Source: https://docs.xcp-ng.org/appendix/answerfile
This is a sample XML answer file used for a fully automated and unattended installation of XCP-ng. It specifies disk configurations, root password, installation source, post-install script, network interface, and timezone.
```xml
sdasdbusmyrootpasswordhttp://pxe.example.org/xcp-ng/
http://pxe.example.org/myscripts/post-install-script
Europe/Paris
```
--------------------------------
### Koji Client Configuration File
Source: https://docs.xcp-ng.org/project/development-process/koji-initial-setup
Example of the `~/.koji/config` file for the Koji client. It specifies the Koji server URLs, web interface, package download site, top directory, and SSL authentication details including client certificate and CA certificate paths.
```ini
[koji]
;url of XMLRPC server
server = https://kojihub.xcp-ng.org
;url of web interface
weburl = https://koji.xcp-ng.org
;url of package download site
topurl = https://koji.xcp-ng.org/kojifiles
;path to the koji top directory
topdir = /mnt/koji
; configuration for SSL authentication
;client certificate
cert = ~/.koji/client.crt
;certificate of the CA that issued the HTTP server certificate
serverca = ~/.koji/serverca.crt
; select authentication type
authtype = ssl
```
--------------------------------
### Build Koji Docker Image
Source: https://docs.xcp-ng.org/project/development-process/koji-initial-setup
Builds a Docker image named 'koji:latest' based on Fedora 41, installing the Koji client within the container. This is an alternative method for running the Koji client.
```dockerfile
docker build -t koji:latest - <
```
--------------------------------
### Install qemu-img and vmfs tools for Local Migration (Bash)
Source: https://docs.xcp-ng.org/installation/migrate-to-xcp-ng
Installs necessary tools for local VMDK to VHD conversion on XCP-ng. Requires enabling specific repositories. These commands should be executed directly on the XCP-ng Dom0.
```bash
yum install qemu-img --enablerepo=base,updates
```
```bash
yum install vmfs6-tools --enablerepo=xcp-ng-lab
```
--------------------------------
### List RPMs within Installer Filesystem
Source: https://docs.xcp-ng.org/project/development-process/ISO-modification
Once chrooted into the installer's filesystem, this command allows you to list all installed RPM packages. This is useful for identifying packages to modify, remove, or update within the installer environment.
```bash
rpm -qa | sort
```
--------------------------------
### XCP-ng Upgrade Answer File Example
Source: https://docs.xcp-ng.org/appendix/answerfile
An example XML answer file used for performing an unattended upgrade of an XCP-ng installation. It specifies the upgrade mode, the existing installation device, the source for upgrade files, and an optional post-install script URL.
```xml
sdahttp://pxehost.example.com/xcp-ng/
http://pxehost.example.com/myscripts/post-install-script
```
--------------------------------
### Xen Configuration for Nested XCP-ng VM
Source: https://docs.xcp-ng.org/guides/xcpng-in-a-vm
This is a configuration example for running XCP-ng using Xen as a nested hypervisor. It specifies HVM builder, memory, VCPUs, disk images, CD-ROM, network interface type ('ioemu'), and boot options. Ensure correct paths for disk images and ISO.
```xenconfig
builder='hvm'
memory = 4096
name = 'xcp-ng'
vcpus=6
pae=1
acpi=1
apic=1
vif = [ 'mac=xx:xx:xx:xx:xx:xx,type=ioemu,bridge=virbr0' ]
disk = [ 'file:/foo/bar/xcp-ng.img,hdc,w', 'file:/foo/bar/xcp-ng/xcp-ng-8.1.0-2.iso,hdb:cdrom,r' ]
boot='dc'
vnc=1
serial='pty'
tsc_mode='default'
viridian=0
usb=1
usbdevice='tablet'
gfx_passthru=0
localtime=1
xen_platform_pci=1
pci_power_mgmt=1
stdvga = 0
serial = 'pty'
hap=1
nestedhvm=1
on_poweroff = 'destroy'
on_reboot = 'destroy'
on_crash = 'destroy'
```
--------------------------------
### Install XCP-ng Updates (yum)
Source: https://docs.xcp-ng.org/management/updates
Installs all available updates for the XCP-ng system using the yum package manager. This command should be run on each server, starting with the pool master.
```bash
yum update
```
--------------------------------
### iPXE over HTTP Installation Configuration
Source: https://docs.xcp-ng.org/installation/install-xcp-ng
This guide details how to use iPXE over an HTTP server for UEFI-based XCP-ng installations. It involves copying installation files to an HTTP root directory and configuring iPXE to chainload GRUB, which then loads the XCP-ng kernel and initrd from the HTTP server.
```bash
tree -L 1 /path/to/http-directory/
.
├── EFI
├── EULA
├── LICENSES
├── RPM-GPG-KEY-CH-8
├── RPM-GPG-KEY-CH-8-LCM
├── RPM-GPG-KEY-Platform-V1
├── boot
└── install.img
```
```text
chain http://SERVER_IP/EFI/xenserver/grubx64.efi
```
```text
# Replace with your server's ip
set root=(http,SERVER_IP)
configfile /EFI/xenserver/grub.cfg
```
```http
# (from python3 -m http.server path-to-directory 80)
192.168.0.10 - - [11/Mar/2021 03:25:58] "GET /boot/xen.gz HTTP/1.1" 200 -
192.168.0.10 - - [11/Mar/2021 03:25:58] "GET /boot/vmlinuz HTTP/1.1" 200 -
192.168.0.10 - - [11/Mar/2021 03:26:03] "GET /install.img HTTP/1.1" 200 -
```
--------------------------------
### Create a VM using XO-CLI
Source: https://docs.xcp-ng.org/guides/create-use-custom-xcpng-ubuntu-templates
This command creates a new virtual machine using XO-CLI, specifying its name, description, template, disk size and storage, CPU/memory allocation, network interface, and cloud-init configuration for user and network setup. It demonstrates advanced VM provisioning beyond the graphical interface.
```bash
$ xo-cli vm.create name_label='my-custom-ubuntu22.04' name_description='Virtual machine based on custom template' template=$TEMPLATE_ID existingDisks=json:'{"0": { "size":21474836480, "$SR":'$STORAGE_ID' } }' CPUs=json:2 memory=json:4294967296 coresPerSocket=json:1 VIFs='json:[{"network":'$NETWORK_ID'}]' cloudConfig="#cloud-config
hostname: vm-ubuntu2204
# ... (rest of cloud-init config)" networkConfig="#network:
version: 1
# ... (rest of network config)"
```
--------------------------------
### xe CLI Basic Syntax and Example
Source: https://docs.xcp-ng.org/management/manage-locally/cli
Demonstrates the fundamental syntax for xe CLI commands, which follows the pattern 'xe =value'. An example is provided for adding a bootable ISO to a VM.
```bash
xe =value =value
```
```bash
xe vm-cd-add uuid=679c70cb-b358-00e1-72c0-819e8f74f00c cd-name=ubuntu-20.04.2-live-server-amd64.iso device=1
```
--------------------------------
### Install AMD MxGPU Supplemental Pack (XCP-ng CLI)
Source: https://docs.xcp-ng.org/compute
Installs the AMD MxGPU supplemental pack on XCP-ng. This is a required step for enabling AMD vGPU functionality. The ISO image must be copied to the host first.
```bash
cd /tmp
ze-install-supplemental-pack mxgpu-2.0.0.amd.iso
```
--------------------------------
### Enable Network and SSH Access During XCP-ng Installation
Source: https://docs.xcp-ng.org/troubleshooting/installation-upgrade
This snippet shows how to configure network settings and enable SSH access with a password during the XCP-ng installation process using kernel command-line parameters. It requires specifying network device and a root password.
```bash
network_device=all sshpassword=YOURCHOICE
```
--------------------------------
### TFTP Server Configuration for BIOS Boot (PXELINUX)
Source: https://docs.xcp-ng.org/installation/install-xcp-ng
This configuration sets up a TFTP server for BIOS-based XCP-ng installations using PXELINUX. It involves creating specific directories and copying necessary boot files from the XCP-ng installation media. The pxelinux.cfg/default file defines the boot menu and kernel parameters.
```text
default xcp-ng
label xcp-ng
kernel mboot.c32
append xcp-ng/xen.gz dom0_max_vcpus=2 dom0_mem=2048M,max:2048M com1=115200,8n1 console=com1,vga --- xcp-ng/vmlinuz xencons=hvc0 console=hvc0 console=tty0 --- xcp-ng/install.img
```
```bash
tree -L 1 /srv/tftp/
srv/tftp
├── mboot.c32
├── pxelinux.0
├── pxelinux.cfg
│ └── default
└── xcp-ng
├── install.img
├── vmlinuz
└── xen.gz
```
--------------------------------
### One-liner to Run Koji Client from Docker
Source: https://docs.xcp-ng.org/project/development-process/koji-initial-setup
A concise command to run the Koji client from a Docker container. It dynamically builds the image using `docker build -q` and then runs the container, mounting the Koji configuration directory and executing `koji moshimoshi`.
```bash
docker run -it --rm -v$HOME/.koji:/root/.koji:ro $(docker build -q - <<<$'FROM fedora:41\nRUN dnf install -qy koji') koji moshimoshi
```
--------------------------------
### Chroot into Installer Filesystem and Mount urandom
Source: https://docs.xcp-ng.org/project/development-process/ISO-modification
This section details how to enter the installer's filesystem using chroot for modifications. It also explains how to mount '/dev/urandom' within the chroot environment, which is necessary for commands like 'yum' and 'rpm' to function correctly inside the installer's context.
```bash
chroot install/
touch install/dev/urandom
mount -B /dev/urandom install/dev/urandom # As root!
```
--------------------------------
### Enable and Start Guest Tools Service on openSUSE Leap
Source: https://docs.xcp-ng.org/vms
Enables and starts the 'xe-linux-distribution.service' using systemctl after guest tools installation and reboot on openSUSE Leap. This ensures the guest tools management daemon runs automatically.
```shell
systemctl enable xe-linux-distribution.service
systemctl start xe-linux-distribution.service
```
--------------------------------
### Start VM After USB Passthrough (XCP-ng CLI)
Source: https://docs.xcp-ng.org/compute
This command starts a virtual machine after a USB device has been attached to it. Ensure the VM is shut down before attaching the USB device and start it with this command afterward.
```bash
[root@xenserver ~]# xe vm-start uuid=
```
--------------------------------
### Branching Strategy for qemu-dp (Git)
Source: https://docs.xcp-ng.org/project/development-process/tags-maintenance-branches-in-our-code
This describes the Git branching and tagging strategy for the 'qemu-dp' component, which uses a fork of the upstream QEMU repository. It outlines how to create branches for tracking XenServer patches, tagging initial release versions, and maintaining XCP-ng releases by branching from specific tags and creating new release tags.
```bash
# For XS patches:
git checkout v
git checkout -b
# ... apply SRPM patches ...
git tag v
# For XCP-ng maintenance:
git checkout v
git checkout -b
git tag v
```
--------------------------------
### Install cryptsetup for LUKS Encryption (Debian)
Source: https://docs.xcp-ng.org/guides/vm-encryption
Installs the necessary cryptsetup package on Debian-based systems to enable LUKS (Linux Unified Key Setup) for disk encryption. This is a prerequisite for setting up encrypted volumes within a VM.
```bash
sudo apt-get update && sudo apt-get install cryptsetup
```
--------------------------------
### VM Install API
Source: https://docs.xcp-ng.org/appendix/cli_reference
Installs or clones a virtual machine from a template. You can specify the template, the target SR, and optionally copy BIOS strings from another host.
```APIDOC
## POST /vm-install
### Description
Installs or clones a virtual machine from a template. You can specify the template, the target SR, and optionally copy BIOS strings from another host.
### Method
POST
### Endpoint
/vm-install
### Parameters
#### Query Parameters
- **new-name-label** (string) - Required - The name for the new VM.
- **template-uuid** (string) - Optional - The UUID of the desired template.
- **template** (string) - Optional - The name or UUID of the desired template.
- **sr-uuid** (string) - Optional - The UUID of the target Storage Repository.
- **sr-name-label** (string) - Optional - The name label of the target Storage Repository.
- **copy-bios-strings-from** (string) - Optional - The UUID of the host from which to copy BIOS strings.
### Request Example
```
POST /vm-install?new-name-label=MyNewVM&template=template_uuid_or_name&sr-uuid=sr_uuid_value
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the installation operation.
#### Response Example
```json
{
"status": "success"
}
```
```
--------------------------------
### Custom ISO - UEFI Boot Configuration Modification (GRUB)
Source: https://docs.xcp-ng.org/installation/install-xcp-ng
Example of modifying the GRUB configuration file within a custom XCP-ng ISO for unattended installation on UEFI systems. It demonstrates appending the answer file parameter to the vmlinuz module line.
```grub
menuentry "install" {
multiboot2 /boot/xen.gz dom0_max_vcpus=1-16 dom0_mem=max:8192M com1=115200,8n1 console=com1,vga
module2 /boot/vmlinuz console=hvc0 console=tty0 answerfile=http://your_server/path/to/answerfile.xml install
module2 /install.img
}
```
--------------------------------
### Install Custom PK Certificate using secureboot-certs
Source: https://docs.xcp-ng.org/guides/guest-UEFI-Secure-Boot
Installs a custom public key (PK) certificate for Secure Boot. The `secureboot-certs install` command is used, followed by the certificate file path. This command can also be used for KEK, db, or dbx certificates.
```bash
# Enroll a custom PK along with the default KEK/db/dbx
secureboot-certs install PK.cer
```
--------------------------------
### Custom ISO - BIOS Boot Configuration Modification (SYSLINUX)
Source: https://docs.xcp-ng.org/installation/install-xcp-ng
Example of modifying the SYSLINUX configuration file within a custom XCP-ng ISO for unattended installation on BIOS systems. It shows how to append the answer file parameter to the kernel command line.
```syslinux
LABEL install
KERNEL mboot.c32
APPEND /boot/xen.gz dom0_max_vcpus=1-16 dom0_mem=max:8192M com1=115200,8n1 console=com1,vga --- /boot/vmlinuz console=hvc0 console=tty0 answerfile=http://your_server/path/to/answerfile.xml install --- /install.img
```
--------------------------------
### Install a Package (Bash)
Source: https://docs.xcp-ng.org/project/development-process/kernel-module-policy
Installs a specified package, making the corresponding module available on the system. This is the primary command for adding new module functionality. After installation, the new module usually takes priority.
```bash
yum install {package-name}
```
--------------------------------
### Extract install.img from ISO
Source: https://docs.xcp-ng.org/project/development-process/ISO-modification
This snippet shows how to extract the 'install.img' file from the ISO contents. This image contains the complete Linux filesystem for the installer. After extraction, the installer's files will be available in the 'install/' directory within the 'iso/' directory.
```bash
cd iso/
mkdir install
cd install
bunzip2 < ../install.img | cpio -idm
cd ..
```
--------------------------------
### Start VM Appliance using xe
Source: https://docs.xcp-ng.org/appendix/cli_reference
Initiates the startup process for a VM appliance, bringing all its contained VMs online. The `paused` parameter can be used to start the appliance in a paused state. Requires the appliance's UUID.
```bash
xe appliance-start uuid=appliance-uuid [paused=true|false]
```
--------------------------------
### Get Package Information (Bash)
Source: https://docs.xcp-ng.org/project/development-process/kernel-module-policy
Retrieves detailed information about a specified package. This command is essential for understanding the contents and dependencies of a module before installation. It takes the package name as an argument.
```bash
yum info {package-name}
```
--------------------------------
### Verify VM Autostart Configuration via CLI - XCP-ng
Source: https://docs.xcp-ng.org/guides/autostart-vm
This command checks the configuration parameters for a specific VM, filtering for 'other-config' to verify that the 'auto_poweron' setting has been applied correctly.
```bash
# xe vm-param-list uuid= | grep other-config
```
--------------------------------
### Configure Bond IP Address via DHCP (Bash)
Source: https://docs.xcp-ng.org/guides/lacp-install-upgrade
This command obtains an IP address for the bond0 interface using DHCP. It is used after configuring the LACP bond when a DHCP server is available on the network. This simplifies network setup during XCP-ng installation or upgrade.
```Bash
dhclient bond0
```
--------------------------------
### Cloud-Init Hostname and User Configuration
Source: https://docs.xcp-ng.org/guides/create-use-custom-xcpng-ubuntu-templates
This Cloud-Init configuration allows for setting the hostname, fully qualified domain name (FQDN), managing the /etc/hosts file, defining a user with a password, and enabling SSH password authentication. It also includes a placeholder for authorized SSH keys.
```yaml
#cloud-config
hostname: vm-ubuntu2204
fqdn: vm-ubuntu2204
manage_etc_hosts: true
user: admin
password: lemotdepasselepluscomplique
chpasswd: {expire: False}
ssh_pwauth: True
ssh_authorized_keys:
- ssh-rsa YOUR_PUBLIC_SSH_KEY
```
--------------------------------
### Create KEK Authentication File (Linux)
Source: https://docs.xcp-ng.org/guides/guest-UEFI-Secure-Boot
Creates a KEK (Key Exchange Key) authentication file using the `create-auth` tool. This is an advanced usage scenario for bundling multiple certificates into a single .auth file. The example shows how to bundle `cert1.crt` and `cert2.crt` into `KEK.auth`.
```shell
/opt/xensource/libexec/create-auth KEK KEK.auth cert1.crt cert2.crt
```
--------------------------------
### Check UEFI/BIOS Mode on XCP-ng Host
Source: https://docs.xcp-ng.org/troubleshooting/installation-upgrade
This command is used on an XCP-ng host to determine if the system is running in legacy BIOS or UEFI mode. The output of 'efibootmgr' indicates the firmware type.
```bash
efibootmgr
```
--------------------------------
### List VMs via CLI - XCP-ng
Source: https://docs.xcp-ng.org/guides/autostart-vm
This command lists all virtual machines on the XCP-ng host, displaying their UUIDs, names, and current power states. The VM UUID is required to configure autostart for individual VMs.
```bash
# xe vm-list
uuid ( RO) :
name-label ( RW) : VM
power-state ( RO) : running
```
--------------------------------
### Check KVM Nested Virtualization Status (Intel)
Source: https://docs.xcp-ng.org/guides/xcpng-in-a-vm
This command checks if nested virtualization is currently enabled for the KVM Intel module. A return value of 'Y' indicates it is active. This is a read-only check.
```Bash
cat /sys/module/kvm_intel/parameters/nested
```
--------------------------------
### Create and Sign KEK Authentication File (Linux)
Source: https://docs.xcp-ng.org/guides/guest-UEFI-Secure-Boot
Creates and signs a KEK authentication file using the `create-auth` tool. This command allows for bundling certificates and signing the authentication file with a custom key, specified by `signer.crt` and `signer.key`.
```shell
/opt/xensource/libexec/create-auth -c signer.crt -k signer.key KEK KEK.auth cert1.crt cert2.crt
```