Skip to main content.

Tracking and cross-compiling -CURRENT (NetBSD)

2014-03-05

Live demo in BSD Now Episode 027 | Originally written by TJ for bsdnow.tv | Last updated: 2014/03/05

NOTE: the author/maintainer of the tutorial(s) is no longer with the show, so the information below may be outdated or incorrect.

In most of the BSDs, there are different branches (or "versions") of the OS that you can use. Often times in addition to the normal releases, there is a development version with the latest features. In addition to the formal releases, NetBSD provides development snapshots and access to the latest code that will be in future versions. Let's get started by checking out the latest source via CVS and setting up a few directories.

# cd /usr
# cvs -d anoncvs@anoncvs.netbsd.org:/cvsroot co -P src
# mkdir -p /usr/obj
# cd src

One of the coolest features of NetBSD is how easy it is to cross-compile (even on another OS)! We'll be using the amazing build.sh script and, for this example, I'm going to build NetBSD on FreeBSD. Adjust "-m amd64" flag to the architecture you want and the "-j 24" flag to the number of CPUs you have. This example is using the GENERIC kernel.

# ./build.sh -m amd64 -O /usr/obj -j 24 tools kernel=GENERIC modules distribution sets

===> build.sh command:    ./build.sh -m amd64 -O /usr/obj -j 24 tools kernel modules distribution sets
===> build.sh started:    Sat Feb 22 17:02:12 EST 2014
===> NetBSD version:      6.99.32
===> MACHINE:             amd64
===> MACHINE_ARCH:        x86_64
===> Build platform:      FreeBSD 9.2-RELEASE amd64
===> HOST_SH:             /bin/sh
===> No $TOOLDIR/bin/nbmake, needs building.
===> Bootstrapping nbmake
checking for sh... /bin/sh
[...]

That's cool and all, but we're assuming you're already on a NetBSD system and want to upgrade your install to -CURRENT. After the build process finishes, you should see something like:

===> Built sets to /usr/obj/releasedir/amd64/binary/sets
===> build.sh ended:      Sat Feb 22 23:37:47 UTC 2014
===> Summary of results:
         build.sh command:    ./build.sh -m amd64 -O /usr/obj -j 24 tools kernel modules distribution sets
         build.sh started:    Sat Feb 22 22:52:16 UTC 2014
         NetBSD version:      6.99.32
         MACHINE:             amd64
         MACHINE_ARCH:        x86_64
         Build platform:      FreeBSD 9.2-RELEASE amd64
         HOST_SH:             /bin/sh
         No $TOOLDIR/bin/nbmake, needs building.
         Bootstrapping nbmake
         MAKECONF file:       /etc/mk.conf (File not found)
         TOOLDIR path:        /usr/obj/tooldir.FreeBSD-9.2-RELEASE-amd64
         DESTDIR path:        /usr/obj/destdir.amd64
         RELEASEDIR path:     /usr/obj/releasedir
         Created /usr/obj/tooldir.FreeBSD-9.2-RELEASE-amd64/bin/nbmake
         Updated makewrapper: /usr/obj/tooldir.FreeBSD-9.2-RELEASE-amd64/bin/nbmake-amd64
         Tools built to /usr/obj/tooldir.FreeBSD-9.2-RELEASE-amd64
         Building kernel:     GENERIC
         Build directory:     /usr/obj/sys/arch/amd64/compile/GENERIC
         Kernels built from GENERIC:
          /usr/obj/sys/arch/amd64/compile/GENERIC/netbsd
         Building kernel modules for NetBSD/amd64 6.99.32
         Successful build of kernel modules for NetBSD/amd64 6.99.32
         Successful make distribution
         Building sets from pre-populated /usr/obj/destdir.amd64
         Built sets to /usr/obj/releasedir/amd64/binary/sets
         build.sh ended:      Sat Feb 22 23:37:47 UTC 2014
===> .

Next we need to install the new kernel.

# cd /usr/obj/sys/compile/arch/amd64/compile/GENERIC
# make install
# shutdown -r now

Once the machine comes back up, we'll install the updated userland.

# cd /usr/src
# ./build.sh -O /usr/obj install=/

There will be some post-install instructions printed after that. Be sure to follow them carefully. One last

# shutdown -r now

and you're done! It's recommended that you subscribe to the current-users mailing list so nothing catches you by surprise. You should also always check /usr/src/UPDATING for special workarounds and important information. See the official documentation for more on how to run -CURRENT.

If you want to create an ISO file of a NetBSD source snapshot, run:

# cd /usr/src
# ./build.sh -m amd64 -O /usr/obj -j 24 release iso-image

make iso-image started at:  Sun Feb 23 00:29:19 UTC 2014
make iso-image finished at: Sun Feb 23 00:29:29 UTC 2014
===> Successful make iso-image
===> build.sh ended:      Sun Feb 23 00:29:29 UTC 2014
===> Summary of results:
         build.sh command:    ./build.sh -m amd64 -O /usr/obj -j 24 release iso-image
         build.sh started:    Sat Feb 22 23:47:25 UTC 2014
         NetBSD version:      6.99.32
         MACHINE:             amd64
         MACHINE_ARCH:        x86_64
         Build platform:      FreeBSD 9.2-RELEASE amd64
         HOST_SH:             /bin/sh
         MAKECONF file:       /etc/mk.conf (File not found)
         TOOLDIR path:        /usr/obj/tooldir.FreeBSD-9.2-RELEASE-amd64
         DESTDIR path:        /usr/obj/destdir.amd64
         RELEASEDIR path:     /usr/obj/releasedir
         Updated makewrapper: /usr/obj/tooldir.FreeBSD-9.2-RELEASE-amd64/bin/nbmake-amd64
         Successful make release
         Successful make iso-image
         build.sh ended:      Sun Feb 23 00:29:29 UTC 2014
===> .

Now we can check what it created:

# file /usr/obj/releasedir/images/*

NetBSD-6.99.32-amd64.iso: # ISO 9660 CD-ROM filesystem data 'NETBSD_69932' (bootable)

You can then burn the new ISO to a CD/DVD and boot from it - talk about portability! The process can even be done without root, just change /usr/obj to somewhere writable by your user and add the "-U" flag for an unprivileged build.

Latest News

New announcement

2017-05-25

We understand that Michael Dexter, Brad Davis, and George Rosamond think there should be more real news....

Two Year Anniversary

2015-08-08

We're quickly approaching our two-year anniversary, which will be on episode 105. To celebrate, we've created a unique t-shirt design, available for purchase until the end of August. Shirts will be shipped out around September 1st. Most of the proceeds will support the show, and specifically allow us to buy...

New discussion segment

2015-01-17

We're thinking about adding a new segment to the show where we discuss a topic that the listeners suggest. It's meant to be informative like a tutorial, but more of a "free discussion" format. If you have any subjects you want us to explore, or even just a good name...

How did you get into BSD?

2014-11-26

We've got a fun idea for the holidays this year: just like we ask during the interviews, we want to hear how all the viewers and listeners first got into BSD. Email us your story, either written or a video version, and we'll read and play some of them for...


Episode 259: Long Live Unix

2018-08-15

Direct Download:MP3 AudioVideo This episode was brought to you by Picking the contest winner 1) Vincent 2) Bostjan 3) Andrew 4) Klaus-Hendrik 5) Will 6) Toby 7) Johnny 8) David 9) manfrom 10) Niclas 11) Gary 12) Eddy 13) Bruce 14) Lizz 15) Jim Random number generator Headlines The Strange Birth and Long Life of Unix They say that when one door closes on you, another opens. People generally...

Episode 258: OS Foundations

2018-08-08

Direct Download:MP3 AudioVideo This episode was brought to you by Headlines FreeBSD Foundation Update, July 2018 MESSAGE FROM THE EXECUTIVE DIRECTOR We’re in the middle of summer here, in Boulder, CO. While the days are typically hot, they can also be quite unpredictable. Thanks to the Rocky Mountains, waking up to 50-degree (~10...

Episode 257: Great NetBSD 8

2018-08-01

Direct Download:MP3 AudioVideo This episode was brought to you by Headlines NetBSD v8.0 Released The NetBSD Project is pleased to announce NetBSD 8.0, the sixteenth major release of the NetBSD operating system. This release brings stability improvements, hundreds of bug fixes, and many new features. Some highlights of the...

Episode 2^8: Because Computers

2018-07-25

Direct Download:MP3 AudioVideo This episode was brought to you by Win Celebrate our 256th episode with us. You can win a Mogics Power Bagel (not sponsored). To enter, go find the 4 episodes we did in December of 2017. In the opening, find the 4 letters in the bookshelf behind me. They...