This document was published in January 2002 issue of DaemonNews magazine

Testdriving -current
Hubert Feyrer, September 2001

Often the latest and greatest (and most unstable :-) features of our favourite BSD release are only available in the -current (development) branch. When running a release version, the question if upgrading the system to -current because of a feature that is only present there is frequently asked. Depending on the feature you want, there is a way to get it going even without upgrading the whole machine to the latest development snapshot.

The idea is to run the -current system in a chroot cage. Of course this comes with some restrictions. If you want to try some new kernel features, that's not possible without booting the new kernel, which is not possible inside a chroot environment. Kernel features include new drivers, changes to the IP stack, new kernel subsystems or APIs for accessing them. If you just want to test some new userland features, library changes (libc, ...) etc., that can be done fine from chroot.

The example motivation for me to set this up was to try out the "sushi" administration tool that comes with NetBSD-current, and that requires a bunch of library updates that aren't easy to do with the latest release. The following description takes NetBSD as an example, showing how to get -current going under the latest release. The steps for FreeBSD/OpenBSD should be similar.

  1. Get the latest snapshot. They can usually be found on in the /pub/NetBSD/arch/<arch>/snapshot directory. Get as much of the "binary/sets" dir as you need, at least base.tgz and etc.tgz are required, comp.tgz is recommended if you want to compile programs.

  2. Decide where to install the -current system. This needs to be a directory where the new system can be installed, it should deliberately be NOT the system's root (/) dir. I'll use /usr/sandbox in this example, and there needs to be enough space to extract the above-mentioned .tgz files.

  3. Unpack the .tgz files:
     # tar pvxCf /usr/sandbox base.tgz
     # tar pvxCf /usr/sandbox etc.tgz
     # tar pvxCf /usr/sandbox comp.tgz
     # ...

    This step populates the new chroot sandbox that will contain the new -current system.

  4. There are a few post-install configurations that one might want to do:

  5. Starting up -current! What we really do here is starting a new process that has it's root (/) directory changed to be our sandbox root directory (/usr/sandbox), that's all. Accessing any absolute path will then be within /usr/sandbox, thus accessing the -current system installed there.

    The command to startup our -current system is:

     # chroot /usr/sandbox
    Consulting the chroot(8) manpage tells us that the process started here is /bin/sh, and if we want a different process started, we can do so by specifying it explicityly:

     # chroot /usr/sandbox /bin/csh 
    Another important point to note that you need to be root to use chroot(8). This can be changed by using the -u switch to chroot:

     # chroot -u joe /usr/sandbox
     $ id
     uid=1000 gid=0(wheel) groups=0(wheel),31(guest)
The steps above should do to get things going for trying a newer version of your operating system. If you want to try a different OS, this won't work, e.g. I wouldn't expect a unpacked FreeBSD or OpenBSD tree to really work well when running a NetBSD tree, but of course it might work to some extent, using compat features.

For running a different operating system at all, maybe even for a CPU you don't have, there are several emulators out there, with VMware probably the most popular one. Others are Bochs and Plex86 all emulating Intel i386 and upward compatible CPUs. If you need to testdrive your code on a IA64 check out ia64sim and Hercules if you want to get a S370 port going.

(c) Copyright 20000110 Hubert Feyrer
$Id: testdriving-current.html,v 1.3 2001/10/03 03:53:25 feyrer Exp $