Trying to make my generic Ubuntu to real time Ubuntu by modifying the kernel by patching / installing RT Linux but couldn\'t find a straight setup. Can someone help with the
Here’s for Ubuntu 19.10 and above and I patched Linux 5.4.5 rt kernel patch because Linux 5.3 -- the base of Ubuntu 19.10 -- has no rt kernel patch.
0. Make a working directory
# Make dir and move to working directory
$ mkdir ~/kernel && cd ~/kernel
1. Download kernel and patch
Download kernel and rt patch from https://www.kernel.org/. You can get these below:
(kernel) https://www.kernel.org/pub/linux/kernel/
(rt patch) https://www.kernel.org/pub/linux/kernel/projects/rt/
Note that the version of rt patch and kernel should be same. I used linux-5.4.5.tar.gz and patch-5.4.5-rt3.patch.gz.
If you download these on the ~/kernel, skip below and move on to step 2.
# Move these zip file to ~/kernel
$ cd ~/Download
$ mv linux-5.4.5.tar.gz patch-5.4.5-rt3.patch.gz ~/kernel/.
2. Extract kernel sources and patch rt kernel
# Extract kernel sources
$ cd ~/kernel
$ tar xvzf linux-5.4.5.tar.gz
# Patch rt kernel
$ cd linux-5.4.5
$ gzip -cd ../patch-5.4.5-rt3.patch.gz | patch -p1 --verbose {}
3. Install required packages
For using menuconfig GUI, libncurses-dev is required. flex and bison will be needed when you compile the kernel.
# For using gui
$ sudo apt install libncurses-dev libssl-dev
# For compiling kernel
$ sudo apt install flex bison
4. Configure kernel for RT
$ make menuconfig
and enter the menuconfig GUI.
# Make preemptible kernel setup
General setup ---> [Enter]
Preemption Model (Voluntary Kernel Preemption (Desktop)) [Enter]
Fully Preemptible Kernel (RT) [Enter] #Select
# Select and
# Check .config file is made properly
Note that there’s no Check for stack overflows option on GUI configuration anymore. You can check it by searching “overflow”. Type / and overflow on Graphical Menu.
5. Compile the kernel
$ make -j20
$ sudo make modules_install -j20
$ sudo make install -j20
6. Make kernel images lighter
As @mrRo8o7 said earlier, big initrd image can occur kernel panic. So you can resolve this problem by:
# Strip unneeded symbols of object files
$ cd /lib/modules/5.4.5-rt3 # or your new kernel
$ sudo find . -name *.ko -exec strip --strip-unneeded {} +
# Change the compression format
$ sudo vi /etc/initramfs-tools/initramfs.conf
# Modify COMPRESS=lz4 to COMPRESS=xz (line 53)
COMPRESS=xz
[:wq]
then update initramfs
$ sudo update-initramfs -u
7. Verify and update grub
Verify that directory and update the grub.
# Make sure that initrd.img-5.4.5-rt3, vmlinuz-5.4.5-rt3, and config-5.4.5-rt3 are generated in /boot
$ cd /boot
$ ls
# Update grub
$ sudo update-grub
8. Reboot and verify
$ sudo reboot
# After the reboot
$ uname -a
then you can check your new kernel version
Linux [PROMPT] 5.4.5-rt3 …