This page provides documentation regarding NetBSD for GRUB developers. NetBSD users wishing to use the current version of GRUB can install it from pkgsrc-wip/grub2 (latest release) or pkgsrc-wip/grub2-current (latest trunk).

NetBSD Kernel Building Mini-Howto

The purpose of this section is to provide a quick and simple recipe for (cross-)building a NetBSD kernel on a Unix-like operating system. For more information, please refer to the The NetBSD Guide, in particular Part V. Building the system.

Getting the sources

To use the cross-platform build system, you need to download the sources of the whole NetBSD system. These sources can be obtained in a number of ways, see Chapter 30. Obtaining the sources of the The NetBSD Guide for details. Apply only one of the following methods to get the sources.

Important note: the source tree of the NetBSD system weighs approximately 1.25 GiB.

Method 1. CVS checkout

This method is not recommended if you have a slow internet connection. Recall that you will be downloading 1.25 GiB...

To download the sources of NetBSD -current, which is the development trunk, use:

cvs -d anoncvs@anoncvs.netbsd.org:/cvsroot checkout -A -P src

If you prefer the sources of NetBSD version 5, which is the stable branch (until -current becomes version 6), use:

cvs -d anoncvs@anoncvs.netbsd.org:/cvsroot checkout -r netbsd-5 -P src

Method 2. Tarball download

This method is not recommended if you have a slow internet connection. You will download a compressed tarball of the sources (approximately 200 MiB). This tarball includes the CVS directories, so you can update it afterwards using the usual CVS commands.

After download, simply unpack the tarball with:

tar -zxvf src.tar.gz

Building a kernel

Create a new directory to hold the generated object files, tools and kernels:

mkdir /usr/build

The following assumes /usr/build but you can replace it with any path of your choice (e.g. a directory inside your account). This step is not necessary, as one may compile directly under the source tree, but I personnally prefer to keep the source tree clean of any generated file.

Now, cd into the src directory that was created by cvs checkout above, and build the toolchain with:

./build.sh -M /usr/build -m <target mach> tools

The desired target machine must be among the supported ports (i386, amd64, sparc64, xen, ...). Once the tools have been built, you may compile a GENERIC kernel with:

./build.sh -M /usr/build -m <target mach> kernel=GENERIC

After compilation, the location of the compiled kernel can be found in the summary that is displayed by build.sh. The above command compiles a GENERIC kernel, but you may choose another configuration file (or create one yourself). These are stored in sys/arch/<target mach>/conf.

Going further

More information on build.sh can be found in Chapter 31. Crosscompiling NetBSD with build.sh. You may also run ./build.sh -h to get the list of options supported by the NetBSD build system. For instance, you can compile a full release of the NetBSD system, and even generate an ISO image of an installation CD, with the following commands:

mkdir /usr/build/myrelease
./build.sh -M /usr/build -m <target mach> -U -R /usr/build/myrelease release
./build.sh -M /usr/build -m <target mach> -U -R /usr/build/myrelease iso-image

Status of NetBSD Loading from GRUB

The NetBSD kernel has its own boot protocol (called knetbsd in the following). Multiboot support has been added to the kernel by Julio M. Merino Vidal. The native boot loader of the NetBSD system supports both boot protocols (knetbsd and multiboot).

This section presents the status of NetBSD booting from GRUB with knetbsd and multiboot, and also compares NetBSD-specific features with the native boot loader.

Test Setup

Test results

Native Loader

GRUB

Feature

Knetbsd

Multiboot

Knetbsd

Multiboot

Comment

boot flags

Yes

Yes

Yes

Yes

Serial console

Yes

Yes

Yes

Yes

Kernel symbol table

Yes

No

Yes

Yes

Video Frame-buffer

Yesa

No

Yesa

Yesa, b

(a) Only for -current. (b) Requires kernel multiboot patch.

Kernel Modules

Yes

Noa

Yes

Noa

(a) Because support is missing in kernel multiboot code, boot-loader supports it.

Miscellaneous Notes


CategoryDeveloper

GrubWiki: NetBSD (last edited 2010-01-17 10:40:02 by VladimirSerbinenko)