Skip to content

Website

OS-RELEASE(5)

Known for its portability, it might come at no surprise that NetBSD (and pkgsrc as well) is also easy to cross build on other platforms and even other hosts. Building NetBSD on Linux can be very convenient, as it's far easier to get access to high-performance Linux powered machines than to NetBSD ones. So let's go through the process and build a NetBSD/amd64 release on a Debian host, using an unprivileged user account.

First, we will need to install some development packages on the host machine:

Copy
apt-get install build-essential zlib1g-dev flex

Then, we can download and extract source sets for the NetBSD version we want to build. At the time of writing, latest NetBSD release is 6.1.4:

Copy
wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.4/source/sets/gnusrc.tgz
wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.4/source/sets/sharesrc.tgz
wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.4/source/sets/src.tgz
wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.4/source/sets/syssrc.tgz

for file in *.tgz do tar xfz $file done

We can now build the cross compiler:

Copy
cd usr/src
./build.sh -U -u -m amd64 tools

Compilation results:

Copy
===> Summary of results:
	 build.sh command:    ./build.sh -U -u -m amd64 tools
	 build.sh started:    Thu Aug 28 21:49:19 UTC 2014
	 NetBSD version:      6.1.4
	 MACHINE:             amd64
	 MACHINE_ARCH:        x86_64
	 Build platform:      Linux 3.2.0-4-amd64 x86_64
	 HOST_SH:             /bin/sh
	 No $TOOLDIR/bin/nbmake, needs building.
	 Bootstrapping nbmake
	 TOOLDIR path:        /home/admin/usr/src/obj/tooldir.Linux-3.2.0-4-amd64-x86_64
	 DESTDIR path:        /home/admin/usr/src/obj/destdir.amd64
	 RELEASEDIR path:     /home/admin/usr/src/obj/releasedir
	 Created /home/admin/usr/src/obj/tooldir.Linux-3.2.0-4-amd64-x86_64/bin/nbmake
	 Updated makewrapper: /home/admin/usr/src/obj/tooldir.Linux-3.2.0-4-amd64-x86_64/bin/nbmake-amd64
	 Tools built to /home/admin/usr/src/obj/tooldir.Linux-3.2.0-4-amd64-x86_64
	 build.sh ended:      Thu Aug 28 21:56:48 UTC 2014

Here is more information about configuration options used in those examples:

Copy
    -U             Set MKUNPRIVED=yes; build without requiring root privileges,
                   install from an UNPRIVED build with proper file permissions.
    -u             Set MKUPDATE=yes; do not run "make cleandir" first.
                   Without this, everything is rebuilt, including the tools.
    -m mach        Set MACHINE to mach; not required if NetBSD native.

Once our toolchain is ready, we can now build NetBSD itself:

Copy
./build.sh -U -u -m amd64 release

Compilation results:

Copy
===> Summary of results:
         build.sh command:    ./build.sh -U -u -m amd64 release
         build.sh started:    Thu Aug 28 21:57:54 UTC 2014
         NetBSD version:      6.1.4
         MACHINE:             amd64
         MACHINE_ARCH:        x86_64
         Build platform:      Linux 3.2.0-4-amd64 x86_64
         HOST_SH:             /bin/sh
         TOOLDIR path:        /home/admin/usr/src/obj/tooldir.Linux-3.2.0-4-amd64-x86_64
         DESTDIR path:        /home/admin/usr/src/obj/destdir.amd64
         RELEASEDIR path:     /home/admin/usr/src/obj/releasedir
         Updated makewrapper: /home/admin/usr/src/obj/tooldir.Linux-3.2.0-4-amd64-x86_64/bin/nbmake-amd64
         Successful make release
         build.sh ended:      Thu Aug 28 23:21:28 UTC 2014

From there, building an ISO image takes only a few seconds:

Copy
./build.sh -U -u -m amd64 iso-image

We can now try to boot the resulting ISO image:

NetBSD Primary Bootstrap

NetBSD Installer

Unsurprisingly, it works as expected! Welcome to NetBSD :-)

Back to top


Copyright © 2009-2026 Jonathan David Allen Moore

Pinned Loading

  1. SYSTEM-OS-OSFree SYSTEM-OS-OSFree Public

    Forked from OS2World/SYSTEM-OS-OSFree

    OSFree source code. OS/2 clone. Reposity copy.

    C

  2. vms37-src vms37-src Public

    Forked from calmsacibis995/vms37-src

    The VAX/VMS 3.7 (1984) source code.

    Fortran

  3. windows-dev-docs windows-dev-docs Public

    Forked from MicrosoftDocs/windows-dev-docs

    Conceptual and overview content for developing Windows apps

    C#

  4. windows-driver-docs windows-driver-docs Public

    Forked from MicrosoftDocs/windows-driver-docs

    The official Windows Driver Kit documentation sources

    OpenSCAD

  5. windowsserverdocs windowsserverdocs Public

    Forked from MicrosoftDocs/windowsserverdocs

    Public content repository for Windows Server content.

Repositories

Showing 10 of 17 repositories

Top languages

Loading…

Most used topics

Loading…