How to build a new kernel on Owl

All Linux vendors have their own ways and requirements to get a framework in place to build a custom kernel, and Owl is no different, though you may actually find it easier doing it “the Owl way” compared to other distributions.

In the instructions below, it is assumed that you are already on Owl and that you have the default set of packages installed.

Sources setup

Prepare the /usr/src/world setup as described in Owl/doc/BUILD, such as by following the download instructions found on the Owl upgrade page (including the otherwise-optional sources download step) or by copying /rom/world from an Owl CD. Depending on the approach you used, you may need to extract the native tree from its tarball:

su - build
rm -rf native
tar xzf native.tar.gz

or maybe extract just the packages sub-tree (it's currently included as a tarball on our x86-64 CDs):

su - build
cd native/Owl
tar xjf packages.tar.bz2

RPM package build

This can be as simple as:

su - build
nice -n19 make PACKAGE=kernel

You will get the kernel*.rpm binary packages under RPMS/ and a build log under logs/kernel.

However, there's little point in you rebuilding the kernel without any changes (you could as well download and use the Owl pre-built kernel RPMs). If you want to make changes, please look inside the native/Owl/packages/kernel/ directory, which contains files like:

-rw------- 1 build sources 41628 Mar 12 18:56 dot-config-i686
-rw------- 1 build sources 37947 Mar 12 18:56 dot-config-x86_64
-rw------- 1 build sources 12704 Mar 27 14:39 kernel.spec
-rw------- 1 build sources 65941 Mar 27 14:39 linux-2.6.18-238.5.1.el5.028stab085.2-owl.diff

It is sensible to make minor edits to dot-config-i686 and/or dot-config-x86_64, but please be sure to also adjust the package revision number by editing EXTRAVERSION in the *-owl.diff patch file and Release in kernel.spec (these must be kept in sync, or the build will fail with File not found: /usr/src/world/rpm-work-1/buildroot/lib/modules/2.6.18-… errors). For example, you might change EXTRAVERSION from -238.5.1.el5.028stab085.2.owl3 to -238.5.1.el5.028stab085.2.owl3.local1 and Release from %ovzversion.owl3 to %ovzversion.owl3.local1 (instead of local, you may use your nickname or your network/company/project name). This is to avoid confusion with Owl official kernel revisions and to allow you to install your RPMs alongside the official ones.

For non-trivial kernel configuration changes (or just to be safe), you may prefer to do a non-RPM'ed kernel build (then either actually use the resulting kernel or just roll your build-tested changes back into the native tree for building an RPM package).

The Owl upgrade wiki page includes instructions on how to install the kernel RPMs.

Non-RPM'ed kernel build

Here's a sample sequence of shell commands. Indeed, the version numbers embedded in filenames will likely be different.

su - build
mkdir kernel; cd kernel # optional
tar xJf ~/sources/Owl/packages/kernel/linux-2.6.18.tar.xz
cd linux-2.6.18
xzcat ~/sources/Owl/packages/kernel/patch-238.1.1.el5.028stab083.1-combined.xz | patch -p1 -T
patch -p1 -Z < ~/native/Owl/packages/kernel/linux-2.6.18-238.5.1.el5.028stab085.2-owl.diff
cp ~/native/Owl/packages/kernel/dot-config-i686 .config # or use dot-config-x86_64 when you're on x86-64
make oldconfig
nice -n19 make -j8 # adjust the ''-j'' option parameter to match the number of logical CPUs for the build to run faster

This will build both the kernel image and modules. To build these separately, use make -j8 bzImage and/or make -j8 modules.

To make kernel configuration changes (before the actual kernel build, indeed), use make menuconfig. To avoid confusion with Owl official kernel revisions, either set CONFIG_LOCALVERSION (in make menuconfig, this is “Local version - append to kernel release” under “General setup”) or edit EXTRAVERSION in the Makefile (do this before you configure the kernel for the first time!)

To install the resulting kernel, copy boot/i386/bzImage (or boot/x86_64/bzImage) and System.map to under /boot, preferably renaming these files to include the kernel version number - e.g., call them vmlinuz-2.6.18-238.5.1.el5.028stab085.2.owl3.local1 and System.map-238.5.1.el5.028stab085.2.owl3.local1. 1) To install modules, use make modules_install as root (beware: if you did not add a LOCALVERSION or change EXTRAVERSION, then this may replace the installed modules from your kernel RPM package, which is bad). Then update the bootloader configuration and reboot the system as described below.

Update the bootloader configuration

Edit your LILO bootloader configuration file (add a new section for the new kernel image) and make your changes take effect:

vi /etc/lilo.conf
lilo

Reboot into the new kernel

1) klogd knows to check for System.map files with such version suffixes.
Owl/kernel-build.txt · Last modified: 2011/08/13 02:09 by solar
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate to DokuWiki Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki Powered by OpenVZ Powered by Openwall GNU/*/Linux Bookmark and Share