Sales | Support:1-888-96LINUX

BYOK (Build Your Own Kernel) Guide

BYOK - Build Your Own Kernel

What's this?

In the BetterLinux releases for CentOS, some features are provided as
binary-only kernel modules. These modules cannot be used with custom kernels,
because binary compatibility across different kernel versions and
configurations is not guaranteed. Build-Your-Own-Kernel gives you the ability
to recompile the BetterLinux kernel modules for your own custom-built kernels.

How does it work?

Each BetterLinux kernel module is implemented as a binary-only part and some
open-source glue that provides a compatibility layer for the binary-only part
across different kernel versions and configurations. The binary-only part is
provided as a non-linked object file (.o) and the open-source part as a source
file (.c). When the whole module is recompiled on the client side, the
compatibility layer is built as usual and linked with the binary-only part.

Which kernels are supported
Theoretically with BYOK all kernels are supported. However we can't test all
the potential kernels (especially if you are using custom patches).

In practice we support CentOS/RHEL 6.x and all LTS vanilla kernels running on CentOS/RHEL 6.x.
We will periodically update the betterlinux-byok RPM, so check if there's an update in our repos
before performing this process.  We will only support BYOK kernel patchsets for the kernels
they were designed for.

Example #1: build a BetterLinux kernel from a 3.14 vanilla kernel

The following instructions document the steps to build a customized BetterLinux
kernel based on 3.14.27, on an otherwise CentOS 6.6 system.

- Create an account on the BetterLinux website (
  and perform a standard installation.  You can later remove our stock CentOS
  kernel, although we recommend against it to ensure a stable environment
  while you establish your own kernel from our patchsets.

- Install our BYOK RPM

$ yum --disableexcludes=all install betterlinux-byok

- Download the Linux kernel source code from

$ wget

- Extract the kernel source tarball:

$ tar xJf linux-3.14.27.tar.xz
$ cd linux-3.14.27

- Apply the corresponding BetterLinux patch:

$ patch -p1 < /etc/betterlinux/byok/patches/betterlinux-3.14-v1.2.3.patch

- Adjust your kernel .config (options required by BetterLinux are enabled by

$ make menuconfig

- Build the custom BetterLinux kernel:

$ make

- Build the BetterLinux kernel modules:

$ rpmbuild --rebuild -D "kversion 3.14.27" -D "kbuilddir $PWD" \

- Install BetterLinux kernel:

$ sudo make modules_install
$ sudo new-kernel-pkg --make-default --host-only --mkinitrd --dracut --depmod --install 3.14.27

- Install BetterLinux kernel modules:

$ sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/betterlinux-kernel-modules*

Example #2: build a BetterLinux kernel from a stock CentOS 6.6 kernel

- Get the latest CentOS rpm from

- Install the source rpm:

$ rpm -ivh kernel-2.6.32-504.3.3.el6.src.rpm

- Copy the all-in-one BetterLinux patch to your source rpm build directory:

$ cp betterlinux-centos6-2.6.32-504.3.3.el6-v1.2.3.patch ~/rpmbuild/SOURCES/

- Edit the stock kernel.spec file to apply the BetterLinux patch during the
kernel build process:

$ vi ~/rpmbuild/SPEC/kernel.spec

- Add the following line:

>>> Patch000001: betterlinux-centos6-2.6.32-504.3.3.el6-v1.2.3.patch

# empty final patch file to facilitate testing of kernel patches
Patch999999: linux-kernel-test.patch

- Add the following line (NOTE: must be before make configs):

>>> ApplyOptionalPatch betterlinux-centos6-2.6.32-504.3.3.el6-v1.2.3.patch

# Dynamically generate kernel .config files from config-* files
make -f %{SOURCE20} VERSION=%{version} configs

ApplyOptionalPatch linux-kernel-test.patch

- Recompile the kernel

$ cd ~/rpmbuild/SPEC
$ rpmbuild -bb --target=`uname -m` --with baseonly --without debug --without debuginfo --without kabichk kernel.spec

- Install kernel and kernel-devel packages:

$ cd ~/rpmbuild/RPMS/x86_64
$ sudo rpm -ivh kernel-2.6.32-504.3.3.el6.x86_64.rpm kernel-devel-2.6.32-504.3.3.el6.x86_64.rpm

- Build BetterLinux kernel modules (ignore git warnings):

$ rpmbuild --rebuild -D "kversion 2.6.32-504.3.3.el6.x86_64" betterlinux-kernel-modules-1.2.3-1.src.rpm

- Install BetterLinux kernel modules:

$ cd ~/rpmbuild/RPMS/x86_64
$ sudo rpm -ivh betterlinux-kernel-modules-1.2.3-1_2.6.32_504.3.3.el6.x86_64.rpm

- Reboot into the new BetterLinux kernel (2.6.32_504.3.3.el6.x86_64)

Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read

Copyright © 2011 All rights reserved.