Xen + NetBSD in Dom0

Speak
Clear All
Xen is a hypervisor free and proven very used even if is being gradually replaced by KVM (which is quite different). This article will detail the installation of Xen on NetBSD 4.1 – 5.1.

It is not necessary to have a processor that supports virtualization except for Windows instructions. But in this tutorial we do not use it.
Installing NetBSD – 5.1

The official NetBSD documentation details summarily Xen3 installing on a version 5.0 of the OS. Although things have probably changed since, it is recommended that the partition / does not more than 512MB and is of type FFSv1.

We’ll compile all the tools from pkgsrc on the same machine. It is possible to do it from a buildbox (cleaner for a production server) but it is better to concentrate on the operation of Xen in our case. In choosing custom installation components (sets) add the development tools and Manual Pages.

Ask to specify the sizes of partitions and use a schema of this type:

/ 384 MB
256MB swap
tmp (SFF) of 256MB
30GB/usr
/ var 256MB
/ home with the rest (install our DomU here)

In the example (as I am doing with VirtualBox) I have a disk 64 GB and here is what this gives:

Continue with the rest of the installation in the classical way.
Configuration of base and preparations

The first thing to do after first boot of your system is to go for a walk in /etc/rc.conf to there set up the network and the host name. Here is an example for a fixed IP machine with SSH access:

hostname = srvxen.src386.org

#Network
auto_ifconfig = YES
ifconfig_wm0 = “inet 192.168.56.90 netmask 255.255.255.0”
defaultroute = 192.168.56.1

#Daemon
sshd = YES

As part of a DHCP server, replace any “Network” paragraph by dhclient = YES. In all cases you must not forget to complete the files/etc/hosts and/etc/resolv.conf. Examples:

# / etc/hosts
: 1 localhost localhost. srvxen.src386.org.
127.0.0.1 localhost localhost. srvxen.src386.org.

# /etc/resolv.conf
# Server DNS (here the box)
nameserver 192.168.1.1

You can now reload the network configuration and start the SSH daemon:

# /etc/rc.d/network restart
# /etc/rc.d/sshd start

We now have access to the internet (you can check this with a ping) which will allow us to install the sources of the system (necessary to compile the kernel later) and pkgsrc (to install Xen).

The literature presents several methods to install pkgsrc. My favorite is to recover the tar.gz from the internet. Note: the following command is valid in 2011 only, see the documentation to be sure:
# cd/root
# ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2011Q2/pkgsrc.tar.gz
# tar – xzf pkgsrc.tar.gz-c-/ usr
# rm pkgsrc.tar.gz

Eventually we must retrieve the NetBSD sources, at least the component “syssrc” that contains the kernel. This chapter of the NetBSD documentation described there also several methods. You can still once use the ftp method:

# cd/root
# ftp-i ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-5.1/source/sets/
….
FTP > mget syssrc.tgz
FTP > exit
# mkdir/usr/src
# tar – xzf./syssrc.tgz UI.
# rm syssrc.tgz

Operation of Xen

Xen is a hypervisor, its task is to share between multiple operating systems access to the hardware. There is no “main” actual bones, the NetBSD that we install will have to turn in Xen. Here are the different components:
xentools4.1
NetBSD-dom0
xenkernel4.1
Equipment

It is our system NetBSD, the dom0 that will have Xen administrative tools and will be able to control all. We will install these components in the following steps.
Compilation of the Dom0 kernel

We start by compiling the Dom0 kernel that will be necessary to boot NetBSD when we will have installed Xen. The sources are located in/usr/src/sys/arch /. In the example I use NetBSD amd64 so I have to enter in the sub directory amd64 kernel configuration files are in the sub directory conf.

# cd/usr/src/sys/arch/amd64/conf

Here is the official documentation for the compilation of the kernel under NetBSD. The configuration to use is XEN3_DOM0. We will install Xen4.1 but it remains compatible:

# config XEN3_DOM0
# cd… / compile/XEN3_DOM0
# make depend
# make
# cp netbsd/netbsd-dom0

Compilation of xentools

Compile and then install Xen and its tools. They are located in/usr/pkgsrc/sysutils/xentools41. However the compilation will not work without a small modification:

# cd/usr/pkgsrc/sysutils /.
# vi Makefile

Find the lines:

# XXX add version check: Xen requires dev86 > = 0.16.14
BUILD_DEPENDS += dev86-[0-9] *:.. /.. / devel/dev86 # needed to build firmware
BUILD_DEPENDS += ocaml-findlib-[0-9] *:.. /.. / devel/ocaml-findlib

And add:

BUILD_DEPENDS += acpica-utils-[0-9] *:.. /.. / sysutils/acpica-utils

Then run the compilation:

# make
# make install

Compilation of xenkernel

Enter the directory/usr/pkgsrc/sysutils/xenkernel41. There also we will have to make a small change to the makefile. Indeed there is a parameter of detection of bone that displays an error and stops the compilation if it is not “supported”. Or it decides that NetBSD – 5.1 is not compatible so that if. We will oust him.

# cd /usr/pkgsrc/sysutils/xenkernel4.1
# vi Makefile

Delete (or comment out) the following lines:

ONLY_FOR_PLATFORM = Linux – 2.6 * – i386 Linux – 2.6 *-x86_64
ONLY_FOR_PLATFORM += NetBSD-[5-9]. 99 * – NetBSD x86_64-[5-9]. 99 *-i386

Then launch the compilation:

# make
# make install

It is now fetching the generated file xen.gz which should be in usr/pkg/xen41-kernel/xen.gz. For convenience we will copy it to the root:

# cp /usr/pkg/xen41-kernel/xen.gz xen.gz

PS: do not try to make symbolic link, because later we will use grub and do not like.
Configuration of daemons

Now let’s set up the launch of different daemons xentools. As indicated during the make install from the latter, need to copy a few files:

# cp /usr/pkg/share/examples/rc.d/xen* /etc/rc.d/

And then allow them in the rc.conf, here is what you should add:

#Xen
xendomains = YES
xEnd = YES
xencommons = YES
xenwatchdog = YES

The boot configuration

The documentation recommends to use grub to boot both our Dom0, namely NetBSD and Xen. Let’s start by installing grub:

# cd/usr/pkgsrc/sysutils/grub /.
# make
# make install

If you already know grub in depth, you know while we will have to write a configuration file and do some hacks. Start by creating a grub on the root directory, and start a menu.lst file:

# mkdir install
VI /grub/menu.lst

The documentation provides a comprehensive sample file, but we can simplify to get this:

default = 0
Timeout = 10

title Xen / NetBSD
root(hd0,0)
kernel (hd0, a) / xen.gz dom0_mem = 65535
module (hd0, a) /netbsd bootdev = wd0a ro console = tty0

title NetBSD BACKUP
root (hd0, 0)
chainloader + 1

GRUB will therefore launch the boot on the Xen kernel, then asked to start the Dom0 that is NetBSD (and give him the ttyS0 (the one that appears by default) terminal. Finalize the installation:

# grub – install – no.-floppy/dev/rwd0d
# grub – no.-floppy – batch
grub > root (hd0, a).
grub > setup (hd0)
grub > quit

You can now reboot your system. You will see Grub and you only have to press the Enter key or waiting

Leave a Reply

Your email address will not be published. Required fields are marked *