See https://wiki.linuxfoundation.org/realtime/documentation/howto/applications/preemptrt_setup and https://stackoverflow.com/questions/51669724/install-rt-linux-patch-for-ubuntu (or alternatively https://medium.com/@patdhlk/realtime-linux-e97628b51d5d).
If the latter is not available (taken from the stackoverflow guide): After applying the patch, you must install some packages (
sudo apt-get install libncurses-dev libssl-dev) (others will be asked for by make / error if they do not exist), then type
make menuconfig and select the Fully Preemptible Kernel (RT) (Processor type and features -> Preemption Model -> Fully Preemptible Kernel (RT), could be located under general settings depending on the kernel version). After that, install the Kernel and apply it:
make -j20 sudo make modules_install -j20 sudo make install -j20
cd /boot ls sudo update-grub
"To change default kernel in grub, edit the GRUB_DEFAULT value in /etc/default/grub to your desired kernel." Then reboot,
uname -a should now indicate that the new kernel is used.
Make sure to install a kernel that fits the current kernel used by your distribution.
If ubuntu is unable to locate the
libncurses-dev package, try again the ubuntu full-scale installation.