Development

Building a new snf-image-helper kernel

The kernel used to boot the helper VM is custom. We build our own kernel because the ones shipped with the major Linux distributions don’t have UFS write support enabled, since it is considered dangerous. The ability to write to UFS file systems is needed in order to support the various *BSD images. In this tutorial we will show how to build a Debian Kernel package using the kernel configuration shipped with the snf-image. The kernel configuration file we provide with snf-image is stripped down. All unnecessary hardware drivers are removed and only the ones that are needed to boot a KVM and a XEN guest are left. In order to recompile a Debian kernel using our configuration file do the following:

Install the dependencies

Install the dependencies for compiling a kernel:

# apt-get install build-essential fakeroot
# apt-get build-dep linux

Download the kernel package:

$ apt-get source linux

Build the packages

Enter the kernel directory:

$ cd linux-<version>

Setup the amd64 configuration:

$ fakeroot make -f debian/rules.gen setup_amd64_none

Copy the snf-image provided configuration to the new kernel:

$ zcat /usr/share/doc/snf-image/kconfig-* > debian/build/build_amd64_none_amd64/.config

Apply the kernel configuration:

$ make -C debian/build/build_amd64_none_amd64 oldconfig
$ cp debian/build/build_amd64_none_amd64/.config debian/build/config.amd64_none_amd64

Change the ABI name (the debian building system will complain otherwise):

$ sed -i 's|abiname: .\+|abiname: 0.snf.image.helper.1|' debian/config/defines
$ fakeroot debian/rules debian/control-real

Add a new entry in debian/changelog with jessie-helper as distribution:

$ dch -D jessie-helper --force-distribution

Build the new kernel package:

$ fakeroot debian/rules source
$ fakeroot make -j <num> -f debian/rules.gen binary-arch_amd64_none

Upload it to an apt repository

If you want to upload the package to a repository, you will need to create a changes file:

$ cp ../linux_<old_version>.dsc ../linux-<new_version>.dsc
$ dpkg-genchanges > ../lunux_<new_version>.changes

And sign it:

$ debsign ../linux_<new_version>.changes

Now you can use dput or dupload to upload the package to a repository.