How to install a NetBSD PV domU on a Debian Squeeze host (Xen 4.0.1)

This mini-HOWTO (largely based on this) describes how to install a para virtualised (PV) NetBSD guest (domU) on a Debian GNU/Linux host (dom0).
Specifically, we use Debian Squeeze (6.0.6) on Xen4 (4.0.1-5.4) as the dom0 and put NetBSD 6.0 in a domU. 
Note that, at the time of writing, the latest stable release of NetBSD is 5.1.2 and that 6.0 is so far only released as release candidates, we use 6.0 due to this incompability between Xen 4.0.1 and NetBSD 5.1.2.
== Prerequisites ==
* A Debian Domain 0 installation
* LVM configured with space for guests in a volume group
* A bridge interface configured, how-to's on this site and on the debian wiki
== Create storage space ==
lvcreate -L4G -n domu-netbsd vgroup
Where 4G is the size (4GB) of the new volume named (/dev/vgroup/domu-netbsd) in the volume group 'vgroup'. You probably want to change the volume name to something corresponding to the name of your guest.
== Download netbsd-INSTALL_XEN3_DOMU and netbsd-XEN3_DOMU kernels ==
=== 64bit/amd64 ===
Download and gunzip to where you want to keep your kernels.
wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.0/amd64/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz
wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.0/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
gunzip netbsd-INSTALL_XEN3_DOMU.gz
gunzip netbsd-XEN3_DOMU.gz
=== 32bit/i386 ===
You probably want the PAE versions, netbsd-INSTALL_XEN3PAE_DOMU and netbsd-XEN3PAE_DOMU, specifically if you get this error
Error: (2, 'Invalid kernel', 'xc_dom_compat_check: guest type xen-3.0-x86_32 not supported by xen kernel, sorry\n')
with the non-PAE ones. Download and gunzip to where you want to keep your kernels.
wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.0/i386/binary/kernel/netbsd-INSTALL_XEN3PAE_DOMU.gz
wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.0/i386/binary/kernel/netbsd-XEN3PAE_DOMU.gz
gunzip netbsd-INSTALL_XEN3PAE_DOMU.gz
gunzip netbsd-XEN3PAE_DOMU.gz
== Create /etc/xen/netbsd.cfg ==
kernel = '/home/user/kernels/netbsd-INSTALL_XEN3_DOMU' # Change this to where you put the kernel from the previous step
memory = '128'
name = 'netbsd'
disk = [ 'phy:/dev/vgroup/domu-netbsd,0x3,w' ]
# The virtual interface
vif = ['bridge=br0']
# where 'br0' is the name of your bridge interface.
== Start VM/domU ==
xm create -c netbsd.cfg
Your system will boot into the NetBSD installer. Example installation at the NetBSD project's site.
== At the end of install == 
If you want to keep the MAC/Ether address given, don't reboot just yet. You'll be brought back to the main install screen, where you must select "e: Utility menu" -> "a: Run /bin/sh", then run 'ifconfig xennet0' and add the address: 00:16:3e:xx:xx:xx (whatever it is, but it need to begin with "00:16:3e") to your vif= line in the /etc/xen/netbsd.cfg at dom0.
vif = ['mac=00:16:3e:xx:xx:xx,bridge=br0']
You can also add the IP adress of the domU within the single quotes with ip=xx.xx.xx.xx.
Now shutdown the domU with 'halt -p'.
== Change to regular kernel ==
Edit /etc/xen/netbsd.cfg, change the first line
kernel = '/home/user/kernels/netbsd-XEN3_DOMU' # Change this to where you put the kernel from the previous step
== Start VM/domU again ==
xm create -c netbsd.cfg
== You're now booted into your brand new NetBSD VM! ==
You'll notice some errors during the bootup, such as "wsconscfg: /dev/ttyEcfg: Device not configured".
To turn this off, edit /etc/ttys and turn off all terminals except "console", like so:
console "/usr/libexec/getty Pc" vt100 on secure
constty "/usr/libexec/getty Pc" vt100 off secure
ttyE0 "/usr/libexec/getty Pc" wsvt25 off secure
ttyE1 "/usr/libexec/getty Pc" wsvt25 off secure
ttyE2 "/usr/libexec/getty Pc" wsvt25 off secure
ttyE3 "/usr/libexec/getty Pc" wsvt25 off secure
...
Also, remove the following line from your domU's /etc/rc.conf:
wscons=YES
Enjoy your new NetBSD box!
See also c33ris2's gentle guide to installing NetBSD in a prgmr DomU (January 2009)
Category:HowTo
Category:Users
Category:Developers
Category:NetBSD
Category:Guest Install