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.

Get the latest snapshot. They can usually be found on ftp.netbsd.org
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.

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.

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

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

Adjust timezone:

# ln -sf /usr/share/zoneinfo/MET /etc/localtime

Create /dev entries for programs that need them:

# cd /usr/sandbox
# cd dev
# sh MAKEDEV all

Drop a kernel in the new system's root dir. It's a good idea to
use a copy of the currently-running kernel so symbols match:

# cp /netbd /usr/sandbox

Configure daemons and services that you want to run as
appropriate. E.g. if you want to use the -current system's new
DHCP, setup /usr/sandbox/etc/dhcpd.conf, for running sendmail
check /usr/sandbox/etc/mail. There are many other places to
tune, please use your system's documentation

Maybe setup a "fstab" that matches your disk config. This can
be as simple as:

# cp /etc/fstab /usr/sandbox/etc

Services can be disabled and enabled using the usual method,
i.e. rc.conf. Be sure to understand that you still have to
start the service scripts from the chroot system's /etc/rc.d
by hand later. Running all of the chroot systems' /etc/rc is
not a good idea, as it might lead to disk corruption, and
clashing servers who want to access the same ports etc.

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:

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.