Categories
DevOps

How to install guest tools inside XCP-ng VM

Install guest tools inside XCP-ng VM for better performance and various features.

Mount guest tools ISO which is available by default on the host operating system.

$ sudo mount /dev/cdrom 
mount: /media/cdrom0: WARNING: source write-protected, mounted read-only.

Determine the directory where it is currently mounted.

$ lsblk /dev/cdrom 
NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0   11:0    1 14.5M  0 rom  /media/cdrom0

Inspect readme file.

$ cat  /media/cdrom0/README.txt 
XCP-ng Tools for Linux (and a word about Windows)
=================================================

This CD contains the XCP-ng Tools and Drivers for supported linux
guest operating systems. You will need to install them to get the best
performance from your virtual machine, and to access advanced features
such as XenMotion.

Windows
-------

We are not allowed to redistribute the windows tools built and signed by
Citrix, so they are not included here.

Refer to our online documentation for instructions:
https://xcp-ng.org/docs/guests.html#windows

Linux
-----

Linux users need to install the guest tools from the /Linux directory on
this CD. This will ensure your Linux VM has access to advanced features
such as XenMotion and in-guest performance metrics.

In addition, we have provided a number of kernel files, which are mostly
based on the vendor-provided kernels, but provide specific enhancements
for improved stability and performance when running on XCP-ng. 
Those are only required for very old VMs since the linux kernel has
included xen drivers by default for many years now.

You can install the required packages by running install.sh like so:

$ /Linux/install.sh

where  is the CD mount point.

To omit the kernel upgrade pass the -k flag to install.sh.

More information on our online documentation:
https://xcp-ng.org/docs/guests.html#linux

FreeBSD
-------

Run the install.sh script, which will offer to download and install
the `xe-guest-utilities` package from FreeBSD's repositories.

More information at https://xcp-ng.org/docs/guests.html#freebsd

List files inside the mounted ISO.

$ ls /media/cdrom0
Linux  README.txt
$ ls /media/cdrom0/Linux/
LICENSE       versions.tgz                            xe-guest-utilities-xenstore-7.20.0-9.i386.rpm    xe-guest-utilities_7.20.0-9_i386.deb    xen-vcpu-hotplug.rules
install.sh    xe-daemon                               xe-guest-utilities-xenstore-7.20.0-9.x86_64.rpm  xe-guest-utilities_7.20.0-9_x86_64.tgz
versions.deb  xe-guest-utilities-7.20.0-9.i386.rpm    xe-guest-utilities_7.20.0-9_386.tgz              xe-linux-distribution
versions.rpm  xe-guest-utilities-7.20.0-9.x86_64.rpm  xe-guest-utilities_7.20.0-9_amd64.deb            xe-linux-distribution.service

Inspect the first lines of the installation script.

$ head -6 /media/cdrom0/Linux/install.sh 
#!/usr/bin/env bash

# Copyright Citrix Systems, Inc.
# All rights reserved.
#
# This script installs or updates the XE support packages installed in a guest.

By default, ISO is mounted with noexec option.

$ mount | grep cdrom
/dev/sr0 on /media/cdrom0 type iso9660 (ro,nosuid,nodev,noexec,relatime,nojoliet,check=s,map=n,blocksize=2048,user)

Remove this option.

$ sudo mount -o remount,ro,exec /dev/cdrom
$ mount | grep cdrom
/dev/sr0 on /media/cdrom0 type iso9660 (ro,nosuid,nodev,relatime,nojoliet,check=s,map=n,blocksize=2048,user)

Display help information for the installation script.

$ /media/cdrom0/Linux/install.sh --help
/media/cdrom/Linux/install.sh: illegal option -- -
usage: install.sh [-d  -m ] [-k]

    -d        Specifies the distro name.
    -m         Specifies the major version of the distro release.
    -k                Do not update the kernel.
    -n                Non interactive mode.

The -d and -m options must be used together. If neither is given then
auto-detection will be attempted.

Execute the installation script.

$ sudo /media/cdrom0/Linux/install.sh 
Detected `Debian GNU/Linux 11 (bullseye)' (debian version 11).

The following changes will be made to this Virtual Machine:
  * update arp_notify sysctl.
  * packages to be installed/upgraded:
    - xe-guest-utilities_7.20.0-9_amd64.deb

Continue? [y/n] y

Selecting previously unselected package xe-guest-utilities.
(Reading database ... 27712 files and directories currently installed.)
Preparing to unpack .../xe-guest-utilities_7.20.0-9_amd64.deb ...
Unpacking xe-guest-utilities (7.20.0-9) ...
Setting up xe-guest-utilities (7.20.0-9) ...

You should now reboot this Virtual Machine.

Reboot the operating system.

$ sudo reboot

Inspect service status.

$ sudo systemctl status xe-linux-distribution.service 
● xe-linux-distribution.service - LSB: Virtual Machine daemon providing host integration services
     Loaded: loaded (/etc/init.d/xe-linux-distribution; generated)
     Active: active (running) since Sun 2021-10-31 19:07:02 CET; 3min 32s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 368 ExecStart=/etc/init.d/xe-linux-distribution start (code=exited, status=0/SUCCESS)
      Tasks: 9 (limit: 1105)
     Memory: 19.1M
        CPU: 154ms
     CGroup: /system.slice/xe-linux-distribution.service
             ├─433 /usr/sbin/xe-daemon -p /var/run/xe-daemon.pid
             └─441 logger -t xe-daemon -p debug

Oct 31 19:07:02 debian systemd[1]: Starting LSB: Virtual Machine daemon providing host integration services...
Oct 31 19:07:02 debian xe-linux-distribution[368]: $Mounting xenfs on /proc/xen: OK
Oct 31 19:07:02 debian xe-linux-distribution[368]: $Detecting Linux distribution version: OK
Oct 31 19:07:02 debian xe-linux-distribution[368]: $Starting xe daemon:  OK
Oct 31 19:07:02 debian systemd[1]: Started LSB: Virtual Machine daemon providing host integration services.
Oct 31 19:07:32 debian xe-daemon[441]: Trigger refresh after system resume

Display VM status using Xen Orchestra.

I like this!