My Virtual LAN using NetBSD/xen

Virtualization allows running several OSes in the same time on the same hardware server. Xen is a (free) virtualization technology that allows modified OS (Xen-aware) to run as virtual machines. Each virtual machines (AKA domU) has it’s own ressources and don’t overlap with others. With a CPU that provides hardware virtualization (VMX), one can also run “native” OS like Microsoft Windows, FreeBSD or OpenSolaris.

Here’s how I installed and configured my Xen environment.

Prerequisites

You will need a VMX enabled CPU to be able to run M$ Windows.

Mine is Intel(R) Core(TM)2 CPU T7400 @2.16GHz. Running “standard” NetBSD on it, you can check that the VMX feature is available :

cpu0: features2 e3bd<SSE3,MONITOR,DS-CPL,VMX,EST,TM2,xTPR>

You also need a NetBSD 5.x CD-ROM.

Check your closer mirror to get it.

Install dom0

Install the minimum requirements:

  • Kernel (GENERIC)
  • Base
  • System (/etc)
  • Online Manual Pages
  • Text Processing Tools

I installed dom0 on a 2GB SD-Card. I “used the entire disk”, configured 128MB of swap and 128MB of tmp (mfs). The root partition is configured as FFSv2 with “log” mount option.

Boot the standard installation and install the following packages:

  • xenkernel33 (or xenkernl3)
  • xentools33 (or xentools3-hvm)

Copy the Xen3 kernel to / and name it /netbsd-xen0.

Edit the /boot.cfg file and, at the beginning, insert the following line:

menu=Boot Xen:load /netbsd-xen0 console=pc;multiboot /usr/pkg/xen3-kernel/xen.gz dom0_mem=256M cpufreq=dom0-kernel

Reboot the machine to enable Xen kernel.

Create the Xen devices:

cd /dev && sh MAKEDEV xen

Configure the automatic daemon start:

# vi /etc/rc.conf
xend=YES
xenbackendd=YES
# vi /etc/rc.local
/usr/pkg/share/examples/rc.d/xend start
/usr/pkg/share/examples/rc.d/xenbackendd start

Start the daemon without rebooting: # sh /etc/rc.local

Configure the Xen bridge:

# cat /etc/ifconfig.bridge0 <
create
!brconfig $int add bge0 up

Install a Windows domU

Running Windows requires the VT to be enabled:

# sudo xm dmesg | grep VMX
(XEN) HVM: VMX enabled

Create the disk image:

dd if=/dev/zero of=disk bs=10m count=2048

Create the configuration file:

name = “winxp”

kernel = “/usr/pkg/lib/xen/boot/hvmloader”
builder=’hvm’

memory = 1024

vif = [ ‘mac=00:16:3e:00:00:13, bridge=bridge0, type=ioemu’ ]
device_model = ‘/usr/pkg/libexec/qemu-dm’

disk = [ ‘file:/home/xen/winxp/disk.img,ioemu:hda,w’,
‘file:/home/xen/winxp.iso,ioemu:hdc:cdrom,r’ ]

boot=’d’

vnc = 1
vncdisplay = 0
vncunused = 0
vncpasswd = “”
vnclisten = ‘127.0.0.1’

usb=1
usbdevice=’tablet’

Start the virtual machine:

xm create /home/xen/winxp.conf

Install Windows using a VNC client.

Install a Debian GNU/Linux domU (HVM)

The Debian system will be install with a standard Linux kernel (not the Xen one).

Create the disk image:

dd if=/dev/zero of=disk.img bs=1m count=4096

Create the configuration file:

name = “debian”

kernel = “/usr/pkg/lib/xen/boot/hvmloader”
builder=’hvm’

memory = 1024

vif = [ ‘bridge=bridge0, type=ioemu’ ]
device_model = ‘/usr/pkg/libexec/qemu-dm’

disk = [ ‘file:/home/xen/winxp/disk.img,ioemu:hda,w’,
‘file:/home/xen/winxp.iso,ioemu:hdc:cdrom,r’ ]

boot=’d’

vnc = 1
vncdisplay = 0
vncunused = 0
vncpasswd = “”
vnclisten = ‘127.0.0.1’

usb=1
usbdevice=’tablet’

Start the virtual machine:

xm create /home/xen/debian.conf

Install Debian GNU/Linux using a VNC client.

Install a Debian GNU/Linux domU

Once the installation is completed using the HVM-way, boot the system (in HVM mode).

Grab the xen-3.3.1.tar.gz archive and run make dist, then install.sh. This will build and install the domU kernel in /boot.

To actually build the Xen kernel, I had to install a lot of packages (apt-get install make gcc hgsvn gawk openssl-headers libssl-dev libx11-dev gettext libncurses5-dev python-dev patch texinfo bzip2 latex). When the installation process is complete, copy the /boot/vmlinuz-2.6.18.8-xen to the dom0 filesystem and shutdown the HVM domU. I did make a copy of the disk just after the HVM installation. This will be my Debian template. I restored the initial disk file before continuing. Another way to get the Xen kernel (and keep it up-to-date) is to use thexen-linux-system-2.6.*-?-xen-68Debian package. Using apt-get”, you’ll get the kernel, the initrd image and the modules. Those can be copied onto the dom0 filesystem and used in the domU’s configuration file.

Modify the debian.conf to boot as a Xen-aware dom0:

name = “debian”

kernel = “/home/xen/zarafa/vmlinuz-2.6.26-1-xen-686”
ramdisk = “/home/xen/zarafa/initrd.img-2.6.26-1-xen-686”
extra = “xencons=tty1”

memory = 1024

vif = [ ‘bridge=bridge0’ ]

disk = [ ‘file:/home/xen/debian/disk.img,ioemu:hda,w’ ]
root = “/dev/hda1 ro”

Start the virtual machine:

xm create -c /home/xen/debian.conf

Configure Debian GNU/Linux to enable remote access.

To be continued…

1 Comment

  • xentutorial.com Sun, 24 Apr 2011 15:27:01 +0000 Reply

    My Virtual LAN using NetBSD/xen…

    Start the daemon without rebooting: # sh /etc/rc.local. Configure the Xen bridge: # cat /etc/ifconfig.bridge0 < create !brconfig $int add bge0 up…

Leave a Reply

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

*

%d bloggers like this: