Chapter 1. The complete guide to building a m0n0wall image from scratch

Table of Contents

1.1. Installing FreeBSD
1.2. Using cvsup to get the latest FreeBSD patches
1.2.1. Installing cvsup
1.2.2. Configuring the supfile
1.2.3. Running cvsup
1.3. make world
1.3.1. Editing /etc/make.conf
1.3.2. making world
1.4. Building the m0n0wall root file system
1.4.1. Creating the root directory structure
1.4.2. Copying required binaries
1.4.3. Preparing /etc
1.4.4. Preparing /dev
1.4.5. Adding the default config.xml
1.4.6. Adding zoneinfo.tgz
1.5. Applying m0n0wall patches for FreeBSD
1.5.1. Userland patches
1.5.2. Kernel patches
1.6. Building the kernel
1.6.1. Compiling and compressing the kernel
1.6.2. Installing the modules
1.7. Building the software packages
1.7.1. PHP
1.7.2. mini_httpd
1.7.3. ISC DHCP server and relay
1.7.4. Dnsmasq
1.7.5. MSNTP
1.7.6. wol
1.7.7. ez-ipupdate
1.7.8. bpalogin
1.7.9. MPD
1.7.10. OpenVPN
1.7.11. racoon
1.7.12. ucd-snmp
1.8. Installing supplementary tools
1.8.1. choparp
1.8.2. atareinit
1.8.3. stats.cgi
1.8.4. minicron
1.8.5. verifysig
1.8.6. runmsntp.sh
1.8.7. linkup scripts
1.9. Building the boot loader
1.9.1. Preparing loader.rc
1.10. Adding the libraries
1.11. Adding the PHP-based configuration scripts
1.12. Adding the webGUI
1.13. Creating mfsroot
1.14. Putting it all together: creating the image
1.15. Creating a bootable CD-ROM version

This guide explains, in detail, all the steps that are required in order to build a complete m0n0wall image from scratch. The primary intention is not that people will use the guide to actually build their own images from scratch, as that is rarely necessary, but to document and preserve all the details so that people who would like to make changes to an existing image can see how m0n0wall and all of its parts are built.

This guide assumes that FreeBSD 4.11-RELEASE is used. Note that there are other ways of doing this, like keeping a separate copy of the FreeBSD source tree and installing world into a subdirectory to leave the build system itself untouched. However, it is assumed that a separate, dedicated (possibly virtual) machine is going to be used for this task anyway, which is also recommended since many steps need to be done as root (among other things to get the file ownership and permissions right without too much effort).

Note that this is not "m0n0wall image building for dummies", and readers are expected to know what they're doing. As such, not all necessary commands and full file paths are listed (the obvious ones have been left out), so don't expect it to work if you just run all the commands listed in this guide.

Finally, many of these tasks can and should be automated (especially the image building part). How this is done is left to the reader - there are no official m0n0wall build scripts.

1.1. Installing FreeBSD

Install FreeBSD 4.11-RELEASE as usual, but use one file system only (i.e. don't create a separate partition for /usr)! See the section about make world for an explanation why this is necessary. Make sure that you choose the "Developer" distribution set. Installing the ports collection is also a good idea.