Installing Xen on NetBSD-5 on VMWare Player

July 26th, 2009

I gave up installing Xen since I can’t find any vmx|svm flags on my debian’s /proc/cpuinfo and/or since I have been unable to make Xen to work on it. The last installation hanged at booting domO process. I can’t remember what the error messages were.

Then I found this awesome page about netbsd/xen.  Combining the info from this page with some trial and error processes of getting the configuration files right, I finally managed to get NetBSD dom0 and domU running.

Installing dom0

  1. Install NetBSD-5 to vmware player as usual (use www.easyvmx.com to get vmplayer config and virtual disks)
  2. Install the followings using pkg_add:
    sysutils/grub
    sysutils/xentools3
    sysutils/xenkernel3
    sysutils/e2fsprogs
  3. cp /usr/pkg/share/examples/rc.d/xen* /etc/rc.d
  4. vi /etc/rc.conf
    xend=YES
    xenbackendd=YES
    xendomains=YES
  5. cd /dev
    sh MAKEDEV xen
  6. Get “netbsd-XEN3_DOM0.gz” from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.0/i386/binary/kernel/ or from netbsd installation iso/cdrom.
  7. Backup original netbsd kernel
    cp /netbsd /netbsd.old
  8. gunzip netbsd-XEN3_DOM0.gz
    mv netbsd-XEN3_DOM0 /netbsd
  9. cp /usr/pkg/xen3-kernel/xen.gz /
    cd /
    gunzip xen.gz
  10. mkdir /grub
    vi /grub/menu.lst
    default=0
    timeout=5
    title XEN3
    root(hd0,0)
    kernel (hd0,a)/xen dom0_mem=128M
    module (hd0,a)/netbsd bootdev=wd0a ro console=pc
    title NetBSD
    root (hd0,0,a)
    kernel /netbsd.old
  11. grub-install ‘(hd0)’
  12. grub –no-floppy
    root (hd0,a)
    setup (hd0)
    quit
  13. vi /etc/ifconfig.bridge0
    create
    !brconfig $int add pcn0 up    # replace pcn0 with your shared network interface.
  14. cd /dev
    sh MAKEDEV all
    sh MAKEDEV xen
  15. shutdown -r now

Installing self-made domU

  1. You need to mount the NetBSD-5 installation cd
    mkdir /mnt/cdrom
    mount /dev/cd0a /mnt/cdrom
  2. Make a directory to contain NetBSD-5 sets
    mkdir /root/lala
  3. Make a directory to contain domU kernel
    mkdir /root/kernels
  4. Get netbsd-XEN3_DOMU.gz from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.0/i386/binary/kernel/ or from netbsd installation iso/cdrom.
  5. cp netbsd-XEN3_DOMU.gz /root/kernels
    cd /root/kernels
    gunzip netbsd-XEN3_DOMU.gz
  6. Extract NetBSD sets:
    tar xzpfe /mnt/cdrom/i386/binary/sets/kern-XEN_DOMU… -C /root/lala
    tar xzpfe /mnt/cdrom/i386/binary/sets/base.tgz -C /root/lala
    tar xzpfe /mnt/cdrom/i386/binary/sets/comp.tgz -C /root/lala
    (… and the rest)
  7. cd /root
    makefs -M 1073741824 lala.ffs lala
    (Note. 1G=1073741824 and 2.5G=2684354560)
  8. A flat swap
    dd if=/dev/zero of=lala/swap bs=1024 count=400
  9. mv lala lala.old
    mkdir lala
    vnconfig vnd0 lala.ffs
    mount /dev/vnd0a lala
  10. vi lala/etc/fstab,
    /dev/xbd0a / ffs rw 1 1
    /swap none swap sw 0 0
    kernfs /kern kernfs rw
    procfs /proc procfs rw,noauto
  11. vi /etc/rc.conf
    rc_configured=YES
    hostname=blah
    dhclient=YES
    sshd=YES
    (… etc)
  12. vi /usr/pkg/etc/xen/nbsd
    kernel = “/root/kernels/netbsd_XEN3_DOMU”
    memory = 256
    name = “nbsd”
    vif = [ 'bridge=bridge0' ]
    disk = ['file:/root/lala.fs,0x01,w']
    root = “xbd0″
  13. To make nbsd domain start at boot
    vi /etc/rc.conf
    xendomains=”nbsd”   # edit this line  add your domains separated by space instead of “YES”
  14. shutdown -r now

Now, you should have NetBSD dom0 and domU running at boot. Use “xm list” to list domains and “xm console ID” to access domU console.

I am new to UNIX,  follow above instructions at your own risk.

References:
NetBSD/xen Howto : www.netbsd.org/ports/xen/howto.html
Xen on NetBSD : www.gutch.de/NetBSD/docs/xen.html
http://pbraun.nethence.com/doc/sysutils/xen_netbsd.html