this is obsolete doc -- see instead

Configuring a NetBSD/XEN dom0 

Update: now with NetBSD 6.0.1 



Install a standard NetBSD system, preferably the 64-bit version (amd64). 



Make sure those packages are installed (I choose the older XEN3 tools to get the HVM package), 

export PKG_PATH=
pkg_add e2fsprogs
pkg_add xenkernel41
pkg_add xentools3
useradd -s /sbin/nologin pbulk
pkg_add xentools3-hvm
#chown pbulk:users /usr/pkg/etc/xen/scripts/qemu-ifup
#chmod 755 /usr/pkg/etc/xen/scripts/qemu-ifup
pkg_add xenvstat
pkg_info | grep xen
#pkg_add xauth xclock
#pkg_info | egrep 'xauth|xclock'

Note. The other available binary packages are, 

#pkg_add xenstoretools
#pkg_add xenkernel33
#pkg_add xentools33


Install the rc scripts, 

cd /etc/rc.d/
cp /usr/pkg/share/examples/rc.d/xendomains .
cp /usr/pkg/share/examples/rc.d/xend .
cp /usr/pkg/share/examples/rc.d/xenbackendd .
ls -l xen*

enable the daemons, 

cd /etc/
cat >> rc.conf <<EOF9


Make sure the drvctl device exists, 

ls -l /dev/drvctl


Make sure /proc/ is mounted by default, 

mount | grep proc
grep proc /etc/fstab


Create the XEN device file, 

cd /dev/
ls -l xen


Building the hypervisor 

Install the XEN microkernel, 

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


Install the NetBSD dom0 kernel, 

cd /
ftp -a
gunzip netbsd-XEN3_DOM0.gz
mv netbsd-XEN3_DOM0 netbsd.xen
chmod +x netbsd.xen
ls -l netbsd*
file netbsd*


Configuring the boot loader 

Prepare the NetBSD boot loader, 

cd /
vi boot.cfg


menu=XEN:load /netbsd.xen;multiboot /xen.gz dom0_mem=256M
#menu=XEN:load /netbsd.xen console=com0;multiboot /xen.gz dom0_mem=256M console=com1 com1=9600,8n1

Note. 'com0' for netbsd, 'com1' (DOS style) for xen.gz ! 


Find out if your root file system is FFSv1 or v2, 

cd ~/
dd if=/dev/rwd0a of=rwd0a.pwet bs=1024k count=1
grep -ai FFS rwd0a.pwet
rm -f rwd0a.pwet


Reinstall the boot loader to apply (change ffsv1/v2 accordingly), 

  installboot -v -o timeout=3 /dev/rwd0a /usr/mdec/bootxx_ffsv2 

  #installboot -v -o timeout=3 -o console=com0 /dev/rwd0a /usr/mdec/bootxx_ffsv2 



Identify the network interface you want to use for management on the dom0 system, 

ifconfig -a


Configure the default bridge, 

cd /etc/
vi ifconfig.bridge0


!brconfig $int add alc0 up

Note. "xenbr0" or "br0" bridge names won't work. Use "bridge0". 



Eventually create a more accessible symbolic link for later use, 

cd /etc/
ln -s ../usr/pkg/etc/xen
ls -l xen


Ready to go 

Restart the system, 

shutdown -r now



Check the currenly used vnode disks once some domU are running, 

vnconfig -l

also, to manually mount a domU filesystem, it's not loop nor losetup you may use on NetBSD, but vnconfig, 

vnconfig vnd0 slackware.11-0.img
mkdir lala
mount_ext2fs /dev/vnd0a lala

Note. "vnconfig -r" for read-only 


Show bridges, 

ifconfig -a
brconfig bridge0


Tips & Tricks 

As for multiboot, to know wheter you're inside XEN or not, even at boot time, 

sysctl machdep.xen_timepush_ticks

so you can enable xend depending on that. Otherwise test for, 

ls -l /kern/xen

but this only works once the system has almost completely booted (mount -a). 



NetBSD/xen Howto : 

Xen on NetBSD : 

How to set up a guest OS using xen3 : 

Bootstrapping a Linux domU from scratch in a NetBSD dom0 : 

Re: linux domU's and partitioning :