Skip to content

Instantly share code, notes, and snippets.

@pbosetti
Last active September 29, 2020 15:37
Show Gist options
  • Save pbosetti/af8c660dc146d6a5122fac4bb689f48c to your computer and use it in GitHub Desktop.
Save pbosetti/af8c660dc146d6a5122fac4bb689f48c to your computer and use it in GitHub Desktop.

How to build deb packages for PREEMPT_RT kernel patch

Install Dependencies

Install compilers required for building the kernel:

$ sudo apt install build-essential git libssl-dev libelf-dev
$ Download and patch

Verify on kernel.org the patches available and pick the most appropriate kernel version:

$ VER=5.4.61
$ VER_RT=5.4.61-rt37

Download the kernel and the rt patch:

$ wget https://kernel.org/pub/linux/kernel/v5.x/linux-$VER.tar.gz
$ wget https://kernel.org/pub/linux/kernel/projects/rt/5.4/patch-$VER_RT.patch.gz

Extract the archive and apply the patch:

$ tar xzvf linux-$VER.tar.gz
$ cd linux-$VER
$ gzcat ../patch-$VER_RT.patch.gz | patch -p1

Configuration

Copy over your old config and use that to configure your new kernel:

$ cp /boot/config-`uname -r` .config
$ make oldconfig

when asked for Preemption Model, select the option “Fully Preemptible Kernel” and accept the default value for the rest.

Alternatively, you could use the graphical interface to configure it using menuconfig. Note that menuconfig requires flex and bison dependencies:

$ sudo apt install flex bison
$ make menuconfig

search for PREEMPT_RT and set it to “Fully Preemptible Kernel (RT)”.

Build and Install

Build the kernel as a debian package using make command

$ make -j8 deb-pkg
$ sudo dpkg -i ../linux-headers-$VER_RT_$VER_RT-1_amd64.deb ../linux-image-$VER_RT_$VER_RT-1_amd64.deb ../linux-libc-dev_$VER_RT-1_amd64.deb

Verification

Reboot your system and check the kernel. It should show PREEMPT_RT

$ uname -a
Linux bmwin864 5.4.61-rt37 #1 SMP PREEMPT_RT Fri Sep 11 17:09:05 CEST 2020 x86_64 x86_64 x86_64 GNU/Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment