How to install non-Debian guests on Debian Dom0, Xen 4.4

From Xen
Jump to navigationJump to search

How to install non-Debian guests on Debian Dom0, Xen 4.4

Overview

Some examples are given on how to install a variety of non-Debian guests with Debian as Dom0 using Xen 4.4.1.

Intended Audience

This is aimed at people who are running Debian 8 (Jessie) on their desktop machine and who are interested in trying-out various other OSs. Although it is hoped that this may be helpful to anyone who has hit a problem with any of the OSs mentioned.

Preconditions

It is assumed that the reader is familiar with Debian Jessie and has already installed Xen (4.4.1 at the time of writing) and LVM and has the machine booting up with Jessie as the Dom0 with 100GB of spare disk space available as an LVM volume group.

The guests' networking should be prepared by setting up the bridge xenbr0 as described in :- http://wiki.xenproject.org/wiki/Xen_Project_Beginners_Guide#Setup_Linux_Bridge_for_guest_networking It is also assumed that the reader has installed Xen-tools and has used xen-create-image to install a Debian PV guest using the instructions found at :-

It should be noted that some older documentation refers to the command 'xm', which has now been replaced by 'xl', although it does keep the same syntax for the rest of the command, such that :-

xm create /etc/xen/jessie.cfg -c

is replaced by :-

xl create /etc/xen/jessie.cfg -c


Which OSs?

Various OSs will be described varying in difficulty and difference from Debian, including :-

  • Devuan (PV) - a Debian fork, using Xen-tools
  • Solaris (OpenIndiana) (PV)
  • PCLinuxOS (HVM)
  • FreeBSD/PCBSD (PVHVM)

Devuan

Devuan is a fork of Debian and can be installed using Xen-tools as mentioned above, but using the Devuan repository as the mirror. However, in the early days of Devuan it was necessary to provide a few extra instructions to the installation process to tell it to install some packages and exclude some others. There was also a problem with the signing of the packages.

The question was, 'how to give these extra instructions?' Xen-tools use debootstrap to carry out the actual installation and it was necessary to pass the instuctions to debootstrap. Although there is no obvious method to pass additional arguments through from xen-create-image, it is possible to specify your own debootstrap command. What was needed was to create a small shell script which simply added in the extra required arguments (--no-check-gpg --include & --exclude) to the original debootstrap, with "$@" passing over the remains of the arguments from the Xen-tools.

There is a question about how much of the configuration is set up in xen-tools.conf or alternatively given on the command line to xen-create-image. In the example below, the conf file has the settings.

Anyway, /etc/xen-tools/mydebootstrap contains :-

#!/bin/bash
/usr/sbin/debootstrap --no-check-gpg --include sysvinit-core,sysvinit,sysvinit-utils --exclude systemd,systemd-sysv,libsystemd0 $@

And make it executable :-

chmod a+x /etc/xen-tools/mydebootstrap

and modify /etc/xen-tools/xen-tools.conf with the new command and the Devuan mirror :-

# install-method = debootstrap:
# debootstrap-cmd = /usr/sbin/debootstrap
debootstrap-cmd = /etc/xen-tools/mydebootstrap
:
:
#
# The default mirror for debootstrap to install Debian-derived distributions
#
# mirror = `xt-guess-suite-and-mirror --mirror`
mirror = http://packages.devuan.org/merged
:
:

Then install with xen-create-image as for a standard Debian guest. You should end up with a guest configuration file /etc/xen/devuan.cfg as follows, although the "dhcp = 'dhcp'" entry is probably historic as in Xen 4.4 you are expected to set-up the networking in the guest itself, only getting the mac address from Xen :-

#
# Configuration file for the Xen instance devuan, created
# by xen-tools 4.5 on Mon May 25 11:25:37 2015.
#

#
#  Kernel + memory size
#


bootloader = '/usr/lib/xen-4.4/bin/pygrub'

vcpus       = '1'
memory      = '1024'

#
#  Disk device(s).
#
root        = '/dev/xvda2 ro'
disk        = [
                  'phy:/dev/HDD0/devuan-disk,xvda2,w',
                  'phy:/dev/HDD0/devuan-swap,xvda1,w',
              ]

#
#  Physical volumes
#

#
#  Hostname
#
name        = 'devuan'

#
#  Networking
#
dhcp        = 'dhcp'
vif         = [ 'mac=00:16:3E:E5:E5:76,bridge=xenbr0' ]

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

The guest OS may then be run and shutdown with the following commands, as root, in the usual way :-

xl create /etc/xen/devuan.cfg -c
^]
xl list
xl shutdown devuan

Solaris

The current fork of OpenIndiana, from OpenSolaris, is build 151a8, at the time of writing, :-

http://openindiana.org/

Much of the information on installing OpenIndiana was updated from :-

The process is to boot from the iso and use OpenIndiana (OI) to install itself onto an LVM logical volume. The installation likes to take a single region of disk and uses ZFS to partition it as required, including swap. It is difficult for pygrub to boot off the ZFS partition, so it is easiest to place a copy of the kernel in Dom0's disc space. OpenIndiana will run paravirtualised.

Create a logical volume for OI to use. It is named 'indy-disk' and is 40G in size. It is assumed in these examples that the LVM logical group is called HDD0 :-

lvcreate -n indy-disk -L 40g HDD0
lvs
  LV             VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  devuan-disk    HDD0 -wi-a-----  10.00g
  devuan-swap    HDD0 -wi-a-----   1.00g
  indy-disk      HDD0 -wi-a-----  40.00g
  jessie-disk    HDD0 -wi-a-----  10.00g
  jessie-swap    HDD0 -wi-a-----   1.00g
  var            HDD0 -wi-ao----   9.31g 
  home           SSD0 -wi-ao----  18.62g
  root           SSD0 -wi-ao----  20.00g

Download the Desktop DVD iso from http://openindiana.org/download/ :-

oi-dev-151a8-live-x86.iso

In these examples the isos have been left in a sub-directory of user1 called 'src'. First mount the iso and copy the kernel (unix) and initial file system (boot_archive) to somewhere convenient in Dom0's disk space (/var/lib/xen), as root :-

mkdir -f /var/lib/xen/kernels/oi151a8
mkdir /mnt/indy
mount -o loop /home/user1/src/oi-dev-151a8-live-x86.iso /mnt/indy
cp /mnt/indy/platform/i86pc/amd64/boot_archive /var/lib/xen/kernels/oi151a8/
cp /mnt/indy/platform/i86xpv/kernel/amd64/unix /var/lib/xen/kernels/oi151a8/
umount /mnt/indy

Set-up the configuration file /etc/xen/indy.cfg For the networking you will need to create a mac address if you want to use dhcp to supply the IP address and if you want the dhcp server configured to give out fixed addresses. Otherwise you do not need to supply a mac address. In the examples the Xen address space is used '00:16:E3:...' with incrementing numbers :-

#
# Configuration file for the Xen instance indy.
#

#
#  Kernel + memory size
#

kernel = "/var/lib/xen/kernels/oi151a8/unix"
ramdisk = "/var/lib/xen/kernels/oi151a8/boot_archive"
extra = "/platform/i86xpv/kernel/amd64/unix -B console=ttya,livemode=text"
# extra = "/platform/i86xpv/kernel/amd64/unix -B zfs-bootfs=rpool/ROOT/openindiana,bootpath=/xpvd/xdf@51712:a"

vcpus       = '1'
memory      = '1024'

#
#  Disk device(s).
#
disk        = [
                  'file:/home/user1/src/oi-dev-151a8-live-x86.iso,xvdc:cdrom,r',
                  'phy:/dev/HDD0/indy-disk,xvda,w',
              ]

#
#  Hostname
#
name        = 'indy'

#
#  Networking
#
vif         = [ 'mac=00:16:3E:00:00:01,bridge=xenbr0' ]

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

Now boot the OpenIndiana LiveDVD

xl create /etc/xen/indy.cfg -c

Proceed and install the OS, login in as jack, password jack, when required. Remember that the first thing that you will have to do as root on your new OS is to change your root password, so you may want to keep your best password for then and use your second best version for the initial setup, when asked for it!

Once the OS has finished installing, shut it down, it does not need to save itself to the 'CD', so we can use 'destroy':-

^]
xl destroy indy

Now reconfigure it to boot off the disk, by changing over the lines 'extra =' from livemode=test to zfs-boot=... and commenting out the cdrom line. It is an advantage of spreading the disk specification over several lines, that any particular entry may be commented out, in situ. The groups of lines changed are :-

kernel = "/var/lib/xen/kernels/oi151a8/unix"
ramdisk = "/var/lib/xen/kernels/oi151a8/boot_archive"
# extra = "/platform/i86xpv/kernel/amd64/unix -B console=ttya,livemode=text"
extra = "/platform/i86xpv/kernel/amd64/unix -B zfs-bootfs=rpool/ROOT/openindiana,bootpath=/xpvd/xdf@51712:a"
:
:
disk        = [
#                  'file:/home/user1/src/oi-dev-151a8-live-x86.iso,xvdc:cdrom,r',
                  'phy:/dev/HDD0/indy-disk,xvda,w',
              ]
:
:

Now OpenIndiana can be booted from the disk :-

xl create /etc/xen/indy.cfg -c

When it is running, you can log in as yourself and run vnc :-

vncserver

you will be prompted for a connection password. On Dom0 you then run, (adjusting the port number from 1 if necessary) :-

vncviewer indy:1

supplying the connection password as required.

PCLinuxOS

PCLinuxOS (PCLOS) is descended from Mandrake Linux and uses RPM packages using 'apt-get' and friends. It will run in HVM mode.

Download a suitable iso from :-

http://www.pclinuxos.com/get-pclinuxos/

At the time of writing the current version is 2014.12 and the author installed the lxde version.

pclinuxos64-lxde-2014.12.iso

Create logical volumes for disk space and for swap, assuming that the volume group is called 'HDD0' :-

lvcreate -n pclos-disk -L 10g HDD0
lvcreate -n pclos-swap -L 1g HDD0

Now set-up the configuration file /etc/xen/pclos.cfg We need to tell Xen that we are using HVM and which device to boot from, where 'd' is the virtual CD for the initial installation and later 'c' for the normal boot off the hard disk. It is also necessary to set up the screen access. Much of the documentation seems to assume that you will use vnc, although it seems slightly easier to get things working with sdl, assuming that you are on a screen attached to Dom0. The documentation recommends setting usbdevice = 'tablet' to improve the mouse action and this seems to work ok in this HVM situation. The network settings are as for Solaris, above, changing the mac address, if required. You may need a suitable keymap entry if you do not have a US keyboard.

Here is the config :-

#
# Configuration file for the Xen instance pclos
#

#
#  How to boot
#

builder = 'hvm'
boot = 'd'
# boot = 'c'

#
#  Disk device(s).
#

disk        = [
                  'file:/home/user1/src/pclinuxos64-lxde-2014.12.iso,hdc:cdrom,r',
                  'phy:/dev/HDD0/pclos-disk,hda,w',
                  'phy:/dev/HDD0/pclos-swap,hdb,w',
              ]

#
# choose vnc or sdl for console
#

vga       = 'stdvga'
videoram  = 16
sdl       = 1
vnc       = 0
vncviewer = 0
vncpasswd = 'S3cr3t'
keymap    = 'en-gb'
usb       = 1
usbdevice = 'tablet'
serial    = 'pty'

#
#  Local set-up
#
#   Limits

vcpus       = '1'
memory      = '1024'

#
#  Hostname
#
name        = 'pclos'

#
#  Networking
#

vif         = [ 'mac=00:16:3E:00:00:02, bridge=xenbr0' ]

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

Boot the iso image as usual with the command :-

xl create /etc/xen/pclos.cfg -c

Select the installation options and proceed as normal. When the installation has finished, edit the configuration file and change the boot option to 'c'. On re-booting it should boot from the hard disk and you should be able to proceed with the new OS. You may comment out the CD line from the 'disk' settings in the configuration file.


FreeBSD/PCBSD

The FreeBSD documentation suggests that if you want a fully configured desktop set-up, then you should probably use PCBSD. From the Xen point of view, the set-up is the same for FreeBSD and PCBSD, although PCBSD does use a fully graphical installer. At the time of writing FreeBSD Stable is on version 10.1 and is avaliable from :-

ftp://ftp.freebsd.org/pub/FreeBSD/releases/ia64/ia64/ISO-IMAGES/10.1/

The author used FreeBSD-10.1-RELEASE-ia64-disc1.iso

PCBSD is currently on point releases of 10.1 and is available from :-

http://www.pcbsd.org/en/download.html

The author used PCBSD10.1.2-05-22-2015-x64-DVD-USB.iso

The installation is happy to take a single logical volume and use ZFS to split up the disk space as required, including swap. These OSs will both use the paravirtualised (PV) drivers with no further action required in the set-up. Possibly because of this the "usbdevice = 'tablet'" should not be used as it stops the mouse from working. Without these usb options the mouse works as intended which includes the virtual desktop requiring a click to grab the focus and then 'ctrl-alt' to release the focus back to your other windows. It is possible that the window, which is opened on your screen, is slightly smaller than the PCBSD desktop, so that you may have to move the view of the desktop around by driving the mouse into the edge of the window.

The example shows FreeBSD, but for PCBSD just change the name of the iso in the file line of the disk description, and possibly also change the name of the image, if you wish.

First we need to create the logical volume

lvcreate -n freebsd-disk -L 40g HDD0

and then the configuration file /etc/xen/freebsd.cfg noting that the usb options have been commented out :-

#
# Configuration file for the Xen instance freebsd
#

#
#  How to boot
#

builder = 'hvm'
boot = 'd'
# boot= 'c'

#
#  Disk device(s).
#
disk        = [
                  'file:/home/user1/src/FreeBSD-10.1-RELEASE-amd64-disc1.iso,hdc:cdrom,r',
                  'phy:/dev/HDD0/freebsd-disk,hda,w',
              ]

#
# choose vnc or sdl for console
#

vga       = 'stdvga'
videoram  = 16
sdl       = 1
vnc       = 0
vncviewer = 0
vncpasswd = 'S3cr3t'
keymap    = 'en-gb'
serial    = 'pty'

# do NOT use 'tablet' as the mouse will not work.
# usb       = 1
# usbdevice ='tablet'
# usbversion = 2

#
#  Memory size
#
vcpus       = '1'
memory      = '1024'

#
#  Hostname
#
name        = 'freebsd'

#
#  Networking
#
vif         = [ 'mac=00:16:3E:00:00:03, bridge=xenbr0' ]

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

As with the previous examples you can now boot the iso image

xl create /etc/xen/freebsd.cfg -c

and perform the installation. When this has finished and a re-boot is required, first edit the configuration file to change the 'boot=' option from 'd' to 'c', so that it will boot from the disk. You should then be able to preceed with using your new OS.