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 267: Absolute FreeBSD

2018-10-10

Direct Download:MP3 AudioVideo Headlines Interview - Michael W. Lucas - mwlucas@michaelwlucas.com / @mwlauthor BR: [Welcome Back] AJ: What have you been doing since last we talked to you [ed, ssh, and af3e] BR: Tell us more about AF3e AJ: How did the first Absolute FreeBSD come about? BR: Do you have anything special planned for MeetBSD? AJ: What...

Episode 266: File type history

2018-10-03

Direct Download:MP3 AudioVideo Headlines OpenBSD/NetBSD on FreeBSD using grub2-bhyve When I was writing a blog post about the process title, I needed a couple of virtual machines with OpenBSD, NetBSD, and Ubuntu. Before that day I mainly used FreeBSD and Windows with bhyve. I spent some time trying to set up...

Episode 265: Software Disenchantment

2018-09-26

Direct Download:MP3 AudioVideo Headlines [FreeBSD DevSummit & EuroBSDcon 2018 in Romania] Your hosts are back from EuroBSDcon 2018 held in Bucharest, Romania this year. The first two days of the conference are used for tutorials and devsummits (FreeBSD and NetBSD), while the last two are for talks. Although Benedict organized the devsummit in large...

Episode 264: Optimized-out

2018-09-19

Direct Download:MP3 AudioVideo This episode was brought to you by Headlines FreeBSD & DragonFlyBSD Put Up A Strong Fight On AMD's Threadripper 2990WX, Benchmarks Against Linux The past two weeks I have been delivering a great deal of AMD Threadripper 2990WX benchmarks on Linux as well as some against Windows and Windows...