The previous article has introduced the installation of the real-time kernel of Ubuntu 18.04, here is the specific installation of the real-time kernel of Ubuntu 16.04.
RTOS
apt-get install build-essential bc curl ca-certificates fakeroot gnupg2 libssl-dev lsb-release libelf-dev bison flex
To find the one you are currently using, use uname -r. The real-time patch is only applicable to some kernel versions, please refer to:
https://www.kernel.org/pub/linux/kernel/projects/rt/
kernel
We recommend choosing the version closest to your current use. The following command assumes the 4.14.12 kernel version with the 4.14.12-rt10 patch. If you choose another version, just replace the number. After confirming the version, use curl to download the source file:
curl -SLO https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.14.12.tar.xz
curl -SLO https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.14.12.tar.sign
curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patch-4.14.12-rt10.patch.xz
curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patch-4.14.12-rt10.patch.sign
And unzip them with the following command:
xz -d linux-4.14.12.tar.xz
xz -d patch-4.14.12-rt10.patch.xz
Once you are sure that the file is downloaded correctly, you can extract the source code and apply the patch:
tar xf linux-4.14.12.tar
cd linux-4.14.12
patch -p1 <../patch-4.14.12-rt10.patch
The next step is to configure the kernel:
make oldconfig
This will open a text-based configuration menu. When asked to provide a preemptive model, select a fully preemptible kernel:
Preemption Model
1. No Forced Preemption (Server) (PREEMPT_NONE)
2. Voluntary Kernel Preemption (Desktop) (PREEMPT_VOLUNTARY)
3. Preemptible Kernel (Low-Latency Desktop) (PREEMPT__LL) (NEW)
4. Preemptible Kernel (Basic RT) (PREEMPT_RTB) (NEW)
> 5. Fully Preemptible Kernel (RT) (PREEMPT_RT_FULL) (NEW)
We recommend leaving the other options at their default values. After that, you can compile the kernel. Because this is a long process, set the multithreading option -j to the number of your CPU cores:
fakeroot make -j4 deb-pkg
Finally, you are ready to install the newly created package. The exact name depends on your environment, but you are looking for headers and images packages without the dbg suffix.
sudo dpkg -i ../linux-headers-4.14.12-rt10_*.deb ../linux-image-4.14.12-rt10_*.deb
Restart the system.
The Grub boot menu should now allow you to select the newly installed kernel. To see which one is currently in use, look at the output of the uname -a command. It should contain the string PREEMPT RT and the version number of your choice. In addition, /sys/kernel/realtime should exist and contain the number 1.
sudo addgroup realtime
sudo usermod -a -G realtime $(whoami)
Then, add the following restrictions to the real-time group /etc/security/limits.conf:
@ realtime soft rtprio 99
@ realtime soft priority 99
@ realtime soft memlock 102400
@ realtime hard rtprio 99
@ realtime hard priority 99
@ realtime hard memlock 102400
Recommended Posts