Saturday, 26 May 2012

CentOS under NetBSD/xen in 15 minutes

The NetBSD site has a howto page on setting up Xen. It runs to... quite a few pages of detail for differing versions and is rather involved.

Recently I needed a test CentOS box and decided to put an underutilised NetBSD/amd64 box to use as my first Xen DOM0 host.

Setup turned out to be surprising simple, so I decided to jot down some brief notes on how to quickly turn a NetBSD-6 box into a Xen DOM0 running a CentOS 5.8 VM. (This covers amd64, but i386 should be almost the same).

 

Converting an existing NetBSD install to Xen DOM0

  • Install xenkernel41 and xentools41 from pkgsrc
  • Extract  kern-XEN3_DOM0.tgz into /netbsd.dom0 (leave /netbsd alone)
  • Add the following to /boot.conf - adjust 512M to the amount to reserve for the DOM0
menu=Xen 512M:load /netbsd.dom0 console=pc;multiboot /usr/pkg/xen41-kernel/xen.gz dom0_mem=512M noreboot
  • Add the following to /etc/rc.conf
xenbackendd=YES
xend=YES
xendomains=YES
xenwatchdog=YES
  • Create /etc/ifconfig.bridge0 with the following - replace bge0 with a suitable Ethernet interface
create
!brconfig $int add bge0 up
  • Reboot and select the Xen option
  • Edit /boot.cfg and change the default= entry to the number of the Xen option

To mis-quote Ken Arnold: "Now that we have a NetBSD DOM0, it would be nice to do something with it, unless you have the social life of a kumquat in which case just running the DOM0 may be enough in itself :)"

Onto setting up the DOMU!

 

Setting up a CentOS DOMU

CentOS provide an Installing CentOS DomU page which was quite helpful for these notes
  • The follow assume all files are in /opt/xen/centos. Adjust to taste
  • Download initrd.img & vmlinuz from http://mirror.centos.org/centos/5.8/os/x86_64/images/xen/
  • Create a file onto which to install. The below is 16G (16304M)
dd if=/dev/zero of=centos.img bs=1m count=16384
  • Create a config file 'centos.cfg' for installing
name = "centos"
memory = "512"
kernel = "/opt/xen/centos/vmlinuz"
ramdisk = "/opt/xen/centos/initrd"
disk = [ 'file:/opt/xen/centos/centos.img,0xca00,w', ]
vif = [ mac=02:00:00:00:00:01, 'bridge=bridge0', ]
vcpus = 1
on_reboot = 'destroy'
on_crash = 'destroy'
  • Start the domain to install, and then connect to the console. Remember Ctrl+] to exit the console
xm create centos
xm console centos
  • Complete the CentOS install, then adjust centos.cfg as vmlinuz & initrd are not needed
name = "centos"
memory = "512"
bootloader = "/usr/pkg/bin/pygrub"
disk = [ 'file:/opt/xen/centos/centos.img,0xca00,w', ]
vif = [ mac=02:00:00:00:00:01, 'bridge=bridge0', ]
vcpus = 1

 

Points to note

  • NetBSD/xen does not yet handle modules. If you need pf or ipf you will need to compile your own DOM0 kernel
  • Not all X drivers run as well under DOM0, the above was done on a server where X was not required
  • If the original NetBSD installation was before 5.0 and has been upgraded you will need to ensure the boot program must be updated
  • If anyone hits any issues with any of the above, drop me a message & I'll be happy to try to help :)

1 comment: