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 steps?
Step 0 - Make a working directory
Make a working directory
#Move to working directory
mkdir ~/kernel && cd ~/kernel
Step 1 - Download kernel and patch
Go to https://www.kernel.org/pub/linux/kernel/ and download a desired version of kernel to ~/kernel. Similarly, go to https://www.kernel.org/pub/linux/kernel/projects/rt/ and download the RT patch with same version as the downloaded kernel version. The kernel and patch I used were linux-4.9.115.tar.gz and patch-4.9.155-rt93.patch.gz.
Step 2 - Unzip the kernel
tar -xzvf linux-4.9.115.tar.gz
Step 3 - Patch the kernel
#Move to kernel source directory
cd linux-4.9.115
gzip -cd ../patch-4.9.115-rt93.patch.gz | patch -p1 --verbose
Step 4 - Enable realtime processing This step requires libncurses-dev
sudo apt-get install libncurses-dev libssl-dev
The next command launches a graphical menu in the terminal to generate the config file.
make menuconfig
Go to the location and make the changes accordingly
##Graphical Menu##
Processor type and features ---> [Enter]
Preemption Model (Voluntary Kernel Preemption (Desktop)) [Enter]
Fully Preemptible Kernel (RT) [Enter] #Select
[Esc][Esc]
Kernel hacking --> [Enter]
Memory Debugging [Enter]
Check for stack overflows #Already deselected - do not select
[Esc][Esc]
[Right Arrow][Right Arrow]
<Save> [Enter]
.config
<Okay> [Enter]
<Exit> [Enter]
[Esc][Esc]
[Right Arrow]
<Exit> [Enter]
Step 5 - Compile the kernel
make -j20
sudo make modules_install -j20
sudo make install -j20
Step 6 - Verify and update Verify that initrd.img-4.9.115-rt93, vmlinuz-4.9.115-rt93, and config-4.9.115-rt93 are generated in /boot directory and update the grub.
cd /boot
ls
sudo update-grub
Verify that there is a menuentry containing the text "menuentry 'Ubuntu, with Linux 4.9.115-rt93'" in /boot/grub/grub.cfg
file
To change default kernel in grub, edit the GRUB_DEFAULT
value in /etc/default/grub
to your desired kernel.
NOTE: 0 is the 1st menuentry
7 - Reboot and verify
sudo reboot
Once the system reboots, open the terminal and use uname -a
to check the kernel version, it should look like the following
Linux abhay-home 4.9.115-rt93 #1 SMP PREEMPT RT Mon May 13 03:32:57 EDT 2019 x86_64 x86_64 x86_64 GNU/Linux
Note: "SMP PREEMPT RT" validates that your system is running real time kernel.
After installing the new kernel (like @Abhay Nayak posted), I got into a kernel panic. The problem was that the initrd image was too big. I solved that with:
Step 1 - Strip the kernel modules
cd /lib/modules/<new_kernel>
find . -name *.ko -exec strip --strip-unneeded {} +
Step 2 - Change the initramfs compression
Edit file /etc/initramfs-tools/initramfs.conf:
COMPRESS=xz
Step 3 - Update initramfs
sudo update-initramfs -u
sudo update-grub2
来源:https://stackoverflow.com/questions/51669724/install-rt-linux-patch-for-ubuntu