NetBSD is a operating system orginally created in the early 90s when it forked from the original BSD. BSD (Berkely Software Distribution) was an early Unix like operating system. Around the time of the final release in the mid 1990s multiple forks of the project has been created, most notably FreeBSD, NetBSD, and OpenBSD. The projects have continued to provide stable operating systems funded by the community. The role the BSD operating system fill is important. Software licensing is tricky, there are two major styles of licensing for open source projects. There's the GNU license, which is what linux is licenses under, and BSD/MIT which is what BSD projects are licensed under. Most open source projects are licensed under one of these license, or a license inspired by these. The distinction between these licenses is important. The GNU license requires all changes made to GNU licensed software to be relased in source under the GNU license. The BSD/MIT licenses are free use, zero libility, which effectively means you are allowed to use and modify the software, including selling it but the original devloper distributes it as is, and is therefore not responsible for any potential losses incured by the use of the software. The permissive license employed by the BSD project has seen BSD operating systems used as the basis for multiple proprietary operating sytems. Included among the list of operating systems built on BSD are the operating systems made for the Playstation 4, Nintendo Switch, and Apple routers.
Getting the NetBSD source can be confusing at first. The project has a more outdated system of cloning than more recent open source projects. This doesn't mean the cloning method is bad, on the contrary it makes it easy to get source for whichever release you want without running into issues with version control. Cloning NetBSD source is done with FTP.
The steps involved in cloning source are
Step 1 Getting Source
Step 2 Unpacking Source
This will leave you with all the source files of the latest version of NetBSD in /usr/src and /usr/xsrc.
Why would you want to build a kernel? There's several applications for building kernels outside of regular devlopment. For pratical applications a kernel can be easilily modified to change the order it loads modules. For certain embedded systems this might be important. From experience I had an issue with a cron startup job crashing at startup because the correct modules weren't loaded at launch. So how does a kernel actually get build, it may be simiplier than you think. There's two ways to do it, I'm going to cover the slightly more in depth, but much quicker way of doing it. For the other way go check out NetBSD build script, this will build everything for a release including the kernel.
Step 1 Create a New Kernel
Note: This builds a amd64 kernel, however the process can be modified easily to produce any of the other supported architectures.
Step 2 Setup Build Script
Step 3 Building
This will only cover how to run the kernel once, to fully replace the kernel consult NetBSD Documentation
Step 1 Place Kernel in Root Directory
Step 2 Reboot and Interupt
After following these steps you should be able to build a new kernel in NetBSD. Modifiying the kernel is a more complex issue I will get into later. This is part of a project to introduce a new kernel API into NetBSD.
Note: A note on syntax, I use # to denote instructions instead of terminal commands
This Week I Learned is an ongoing project where one of us here at JATAS writes a short article on an interesting topic we learned some new (to us) information about this week. Even if there isn't a large quantity of information to share, you can be sure it is quality!
This artical was written by Alec.