Nethence Newdoc Olddoc Lab Your IP BBDock  


Warning: those guides are mostly obsolete, please have a look at the new documentation.

UnixWindowsOracleObsoleteHardwareDIYMechanicsScriptsConfigs

Configuring a NetBSD/XEN dom0
Update: now with NetBSD 6.0.1
 
Introduction
Install a standard NetBSD system, preferably the 64-bit version (amd64).
 
Requirements
Make sure those packages are installed (I choose the older XEN3 tools to get the HVM package),
export PKG_PATH=ftp://ftp.fr.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/6.0/All
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
xend=yes
xenbackendd=yes
xendomains=yes
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
./MAKEDEV xen
 
Building the hypervisor
Install the XEN microkernel,
cd /
cp /usr/pkg/xen41-kernel/xen.gz .
 
Install the NetBSD dom0 kernel,
cd /
ftp -a ftp://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-6.0.1/amd64/binary/kernel/netbsd-XEN3_DOM0.gz
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
add,
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 
 
Networking
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
like,
create
!brconfig $int add alc0 up
Note. "xenbr0" or "br0" bridge names won't work. Use "bridge0".
 
Configuration
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
 
Troubbleshooting
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).
 
References
NetBSD/xen Howto : http://www.netbsd.org/ports/xen/howto.html
Xen on NetBSD : http://www.gutch.de/NetBSD/docs/xen.html
How to set up a guest OS using xen3 : http://wiki.netbsd.se/How_to_set_up_a_guest_OS_using_xen3#Updating_.2Fboot.cfg
Bootstrapping a Linux domU from scratch in a NetBSD dom0 : http://mail-index.netbsd.org/port-xen/2007/04/05/0000.html
Re: linux domU's and partitioning : http://mail-index.netbsd.org/port-xen/2006/12/04/0007.html
 

(obsolete, see the new doc)