1.4. Building the m0n0wall root file system

The following steps assume that your m0n0wall root file system will be built in $MWROOT, so create a directory to hold the root file system and set MWROOT to point to it.

1.4.1. Creating the root directory structure

mkdir bin cf conf.default dev etc ftmp mnt modules proc root sbin tmp usr var
mkdir etc/inc
ln -s /cf/conf conf
cd usr
mkdir bin lib libexec local sbin share
cd local
mkdir bin captiveportal lib sbin www
ln -s /var/run/htpasswd www/.htpasswd
  • /cf is where the Compact Flash card (or the hard disk, or the floppy disk) is mounted later on

  • /conf.default contains the factory default config.xml

  • /conf (or /cf/conf effectively due to the symlink) contains the current config.xml

  • /ftmp is used to mount a temporary memory file system during a firmware upgrade through the webGUI

  • /etc/inc contains PHP include files that are used by both the boot scripts and the webGUI

  • /usr/local/www contains the webGUI pages

  • /usr/local/captiveportal is the web root directory for the HTTP server process to which HTTP connections are redirected if the captive portal is on and the user hasn't authenticated yet

  • the symbolic link for .htpasswd is required as the boot scripts will write the webGUI user/password to /var/run/htpasswd

1.4.2. Copying required binaries

To facilitate this, a list of binaries that need to be copied is provided along with a simple perl script to copy them over (taken from the miniBSD tutorial). Download the script from http://m0n0.ch/wall/downloads/freebsd-4.11/mkmini.pl and the list of binaries from http://m0n0.ch/wall/downloads/freebsd-4.11/m0n0wall.files.

perl mkmini.pl m0n0wall.files / $MWROOT

1.4.3. Preparing /etc

Most of the base contents of /etc aren't very interesting, so they're available as a tarball to save the time it would take to put them together from FreeBSD sources. Download from http://m0n0.ch/wall/downloads/freebsd-4.11/etc.tgz and extract as follows:

tar -xzf etc.tgz -C $MWROOT Adding /etc/version

/etc/version holds the version number of the image. Create with e.g.

echo "1.21" > $MWROOT/etc/version Adding /etc/version.buildtime

/etc/version.buildtime is displayed in the webGUI. Create as follows:

date > $MWROOT/etc/version.buildtime Adding /etc/platform

/etc/platform identifies the platform for which the image is built and is very important, as the PHP scripts use it to determine e.g. how the configuration is to be stored or which options should be available in the webGUI. Possible values are:

  • net45xx

  • net48xx

  • wrap

  • generic-pc

  • generic-pc-cdrom

echo "net45xx" > $MWROOT/etc/platform

1.4.4. Preparing /dev

FreeBSD 4.x doesn't have devfs yet, so we need to add a few essential device files. You could copy the contents of /dev on your FreeBSD box or use MAKEDEV; however, that would result in many device files that aren't necessary. A tarball of all the devices that are typically needed in m0n0wall is provided at http://m0n0.ch/wall/downloads/freebsd-4.11/dev.tgz. Extract as follows:

tar -xzf dev.tgz -C $MWROOT

1.4.5. Adding the default config.xml

Download the latest default config.xml from http://m0n0.ch/wall/downloads/config.xml and put it in $MWROOT/conf.default/config.xml.

1.4.6. Adding zoneinfo.tgz

FreeBSD keeps time zone information files in /usr/share/zoneinfo. In order to save space, m0n0wall uses a stripped down version of the contents of that directory and keeps them in a tarball. Download zoneinfo.tgz from http://m0n0.ch/wall/downloads/freebsd-4.11/zoneinfo.tgz and place it in $MWROOT/usr/share/zoneinfo.tgz.