Last active
November 29, 2023 03:04
-
-
Save Tekunogosu/7870f733cf3ba5c84c3afe7ff58ef733 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Make sure the kernel in use has a real time patch available for it. | |
## Check the below patch site for a patch for the appropriate kernel | |
## For gentoo, its usually necessary to emerge a specific version of the kernel as not all version have a patch set | |
## Using different kernel than the one you're using also allows you to switch between a working version if something goes wrong | |
## You need to make sure the exact version matches, example: 5.15.65 is exact version I used | |
## Patch site | |
## https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.15/ | |
## Emerge new kernel | |
## most likely have to unmask the specific version to match the real time patches | |
## example | |
echo "sys-kernel/gentoo-sources:5.15.65" >> /etc/portage/package.accept_keywords/gentoo-sources-5.15.65 | |
## emerge the specified sources you want to patch | |
emerge -av gentoo-sources:5.15.65 | |
## set kernel to the new version | |
eselect kernel list | |
eselect kernel set # | |
## change directory to the select kernel sources | |
cd /usr/src/linux | |
## Download the patch and place it in your /usr/src/linux directory | |
## this is the specific version for 5.15.65 and place it in your /usr/src/linux directory | |
wget https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.15/patches-5.15.65-rt49.tar.gz | |
## copy over the old .config | |
## I recommend making a backup of the .config of your old working kernel BEFORE you patch and update the .config | |
cp /usr/src/<old version>/.config /usr/src/linux/.config | |
## download single patch and use the following command to patch it | |
zcat patches-5.15.65-rt49.tar.gz | patch -p1 | |
## cd to kernel source dir and update the .config | |
## this will prompt with the new changes, if you're updating to a minor version there will really only be like 3 options | |
## if your moving to a different major version like from 5.15 to 5.19, then there will be a lot more options. | |
make olddefconfig | |
## compile the kernel | |
## set '24' to be the amount of jobs you want to spawn when compiling, my pc has lots of cores | |
make -j 24 && make modules_install && make install | |
## create new initramfs -- I use dracut but you could use genkernel too | |
dracut --hostonly --kver 5.15.65-gentoo-rt | |
## Update Grub (I use grub) or whatever you use | |
grub-mkconfig -o /boot/grub/grub.cfg | |
## recompile the nvidia drivers with a specific flag set to allow realtime kernel. Otherwise nvidia drivers fail | |
IGNORE_PREEMPT_RT_PRESENCE=1 emerge -av nvidia-drivers | |
## Portage can be configured to set this environment variable everytime you compile the nvidia-drivers using package.env | |
## First make the following directories as they aren't created by default on the system | |
mkdir /etc/portage/{package.env, env} | |
## add the following to /etc/portage/env/nvidia-drivers.config | |
IGNORE_PREEMPT_RT_PRESENCE=1 | |
## add the following to /etc/portage/package.env/nvidia-drivers | |
echo "x11-drivers/nvidia-drivers nvidia-drivers.conf" >> /etc/portage/package.env/nvidia-drivers | |
## When you emerge nvidia-drivers in the future it will have the IGNORE_PREEMPT_RT_PRESENCE variable set. | |
## Sadly it doesn't look like there is a way to see this variable with emerge --info nvidia-drivers, but it does seem to work. | |
## Reboot and select new kernel | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment