Table of Contents

  1. Disk Preparation
  2. Base System and Ports Installation
  3. Networking Configuration
  4. User Accounts
  5. SSH Configuration
  6. Setting up the Development Jail
  7. Entering the Development Jail
  8. CVSup Installation and Configuration
  9. Rebuilding World
  10. Onward!

Introduction ^

All of this information is available elsewhere on the Web. The m0n0wall developer documentation has a fantastic image building guide based on FreeBSD 4.11 and Ultradesic has an extensive minibsd development guide (stripping-down FreeBSD 6.x).
There are, however, some differences between 4.11 and 6.2 in the m0n0wall guide and the jail setup from the Ultradesic guide is not described.

This document aims to integrate the existing documentation, producing a single guide for people interested in setting up an environment for m0n0wall development.

People familiar with FreeBSD can skim, following the bolded instructions.

Changelog ^

2007-03-02 - fixed a typo in the jail prep section (Thanks Paul T.)
2007-02-22 - first draft

1. Disk Preparation ^

  • After selecting your country and keyboard layout, select “standard” install from the menu.
  • Confirm the fdisk screen and press ‘a’ to create a single slice on the disk.
  • Press ‘q’ to leave the editor.
  • Select ‘OK’ from the next screen to install the boot manager onto the disk.
  • Confirm the next partitioning screen and press ‘c’ to create your first partition. The first partition we will create is the swap partition.
  • Enter an appropriate value here for its size.1
  • Select ‘Swap’ and then ‘OK’.
  • Press ‘c’ to create another partition.
  • Select ‘OK’ to use the remainder of the disk for our root filesystem.
  • Select ‘FS’ because we truly do want a file system.
  • Enter ‘/’ (without ticks) as the mount point and continue.
  • Press ‘q’ to leave the editor.

2. Base System and Ports Installation ^

  • Select ‘Developer’ from the list of distribution sets.
  • Select ‘Yes’ to install the ports collection.
  • Back on the Distributions screen, press ‘OK’.
  • Confirm ‘CD/DVD’ as the installation media.
  • Read this and make sure you aren’t about to accidently tromp an existing install of something. The install takes a few minutes.
  • Accept the congratulations.

3. Networking Configuration ^

  • Select ‘Yes’ to setup a network card.
  • Select your card from the list.
  • Answer the ‘IPv6′ and DHCP questions appropriately.
  • If you didn’t use DHCP, fill out your network info and continue.
  • Select ‘OK’ to bring up the network card.
  • ‘No’ to being a gateway, ‘No’ to inetd.
  • Select ‘Yes’ to enable SSH logins.
  • ‘No’ to Anonymous FTP, ‘No’ to being a NFS Server and ‘No’ to being a NFS Client
  • ‘No’ to needing any additional system console settings.
  • Follow the prompts and set the time zone.
  • ‘No’ to Linux Binary Compatibility
  • Mouse?
  • Answer ‘No’ to browsing the package collection.

4. User Account(s) ^

  • Add any initial users if you want them. If this is only a development box, you probably won’t ever need one.
  • Set the root password.
  • Answer ‘No’ to the ‘last options’ screen.
  • Exit the installer.

5. SSH Configuration ^

  • After the machine reboots, log in as root.
  • If you’ll be accessing the box over SSH and only have a root account, you’ll need to enable root logins over SSH:
    • edit: /etc/ssh/sshd_config
    • uncomment and change ‘PermitRootLogin=no’ to ‘yes’

6. Setting up the Development Jail ^

m0n0wall needs to have some of the base-system binaries patched. Because of this, it’s desirable to have a “sandbox” to work in so we don’t ruin the system we’re developing on. We’ll now use sysinstall to install our jail at /usr/jail.

  • Run sysinstall.
  • Select ‘Custom’ installation.
  • Select ‘Options’.
  • Make sure that ‘Release Name’ is set to ‘6.2-RELEASE’
  • Change the Install Root from ‘/’ to ‘/usr/jail’
  • Press ‘q’ to leave the options editor.
  • Select ‘Distributions’ and select the ‘Developer’ distribution just we did during the install.
  • Answer ‘Yes’ again to the ports question.
  • Select ‘Exit’.
  • Select ‘Commit’ and your installation media to start the jail installation process.
  • When the installation process is finished, answer ‘No’ to the dialog asking if you’d like to set any last options.
  • Select ‘Exit’ and then ‘X Exit Install’ to exit sysinstall.

7. Entering the Development Jail ^

The easiest way to prepare and chroot into your new development jail is to download this script from the ultradesic documentation.

# fetch http://www.ultradesic.com/pub/miniBSD_Files/minichroot.sh
# chmod 700 minichroot.sh

It does the following:

  • copies a few important from the host system into the jail (resolv.conf, localtime, wall_cmos_clock)
  • mounts the device system in the jail
  • chroots into the jail

Add the following line to /usr/jail/root/.cshrc so your prompt lets you know which environment you are in:

set prompt = "MiniBSD %~ %# "

That’s it. Execute the script to enter the development jail.

8. CVSup Installation and Configuration ^

These instructions can also be used to update your host-system’s sources.

Install the cvsup-without-gui package so you can update your jail’s system sources

# pkg_add -r cvsup-without-gui
# rehash

Next, copy the sample stable-supfile into /etc and make it writable

# cp /usr/share/examples/cvsup/stable-supfile /etc/supfile
# chmod 600 /etc/supfile

Add a line to the supfile so that cvsup updates our ports tree as well.

# echo "ports-all tag=." >> /etc/supfile

Change the following line to set your cvs host to a mirror close to you.

* default host=CHANGE_THIS.FreeBSD.org

Change the ‘cvs tag’ line so we sync the OS sources to Release 6.2:

* default release=cvs tag=RELENG_6_2

And finally, sync your source tree.

# cvsup -g -L 2 /etc/supfile

9. Rebuilding World ^

These instructions are specific to rebuilding world in your jail (i.e. not switching to single-user to install world and not building the kernel). Follow the extra warnings to rebuild world for your host system.

Add a line to /etc/make.conf so the system binaries will be linked dynamically, saving space.

# echo "NO_SHARED=no" >> /etc/make.conf

We’re finally ready to rebuild the system! Execute the following two commands, take a break and go find a coffee.

# cd /usr/src
# make -j4 buildworld

Warning: Only execute these commands if you are rebuilding your host system. This drops you into single-user mode.

# shutdown now  # confirm the default shell
# cd /usr/src

Now, we’ll install the freshly compiled world.

# make installworld

Warning: Only execute these commands if you are rebuilding your host system. This recompiles and installs your updated kernel. Finally, reboot to use your new system.

# make buildkernel
# make installkernel
# reboot

10. Onward! ^

Your development system is ready for use. To keep you productively marching along, we’ve written m0n0dev, a tool that will automate the steps found in the image building guide taking into account the changes between 4.11 and 6.2.

  1. FreeBSD recommends that this value be twice the amount of RAM present in your system.