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

Hi, Mr. Dexter. Also, we understand that Brad Davis thinks 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 220: Opening ZFS in 2017

2017-11-15

Direct Download:HD VideoMP3 AudioTorrent This episode was brought to you by Headlines The First PS4 Kernel Exploit: Adieu The First PS4 Kernel Exploit: Adieu Plenty of time has passed since we first demonstrated Linux running on the PS4. Now we will step back a bit and explain how we managed to jump...

Episode 219: We love the ARC

2017-11-08

Direct Download:HD VideoMP3 AudioTorrent This episode was brought to you by Headlines Papers We Love: ARC: A Self-Tuning, Low Overhead Replacement Cache Ever wondered how the ZFS ARC (Adaptive Replacement Cache) works? How about if Bryan Cantrill presented the original paper on its design? Today is that day. Slides It starts by looking back at a fundamental paper...

Episode 218: A KRACK in the WiFi

2017-11-01

Direct Download:HD VideoMP3 AudioTorrent This episode was brought to you by Headlines FreeBSD 10.4-RELEASE Available FreeBSD 10.4-RELEASE is out. The FreeBSD Project dedicates the FreeBSD 10.4-RELEASE to the memory of Andrey A. Chernov. Some of the highlights: 10.4-RELEASE is the first FreeBSD release to feature full support for eMMC storage, including eMMC partitions, TRIM...

Episode 217: Your questions, part II

2017-10-25

Direct Download:HD VideoMP3 AudioTorrent This episode was brought to you by Headlines OpenBSD 6.2 Released OpenBSD continues their six month release cadence with the release of 6.2, the 44th release On a disappointing note, the song for 6.2 will not be released until December Highlights: Improved hardware support on modern platforms including ARM64/ARMv7 and octeon,...