Created
August 4, 2022 14:40
-
-
Save EricCousineau-TRI/91a035538cd9b67a72b771600eaa64f9 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
| #!/bin/bash | |
| set -eux | |
| cat <<EOF | |
| Real-time kernel patching. Per: | |
| https://frankaemika.github.io/docs/installation_linux.html | |
| The just scriptifies stuff. | |
| EOF | |
| sudo apt-get install build-essential bc curl ca-certificates gnupg2 libssl-dev lsb-release libelf-dev bison flex dwarves zstd libncurses-dev | |
| rm -rf ~/tmp/rt_kernel && mkdir -p ~/tmp/rt_kernel | |
| cd ~/tmp/rt_kernel | |
| curl -SLO https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.9.1.tar.gz | |
| curl -SLO https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.9.1.tar.sign | |
| curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/5.9/patch-5.9.1-rt20.patch.gz | |
| curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/5.9/patch-5.9.1-rt20.patch.sign | |
| gzip -d *.gz | |
| ( | |
| gpg2 --verify linux-*.tar.sign | |
| gpg2 --verify patch-*.patch.sign | |
| ) || ( | |
| echo "Run: gpg2 --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys <key>" | |
| exit 1; | |
| ) | |
| tar xf linux-*.tar | |
| cd linux-*/ | |
| patch -p1 < ../patch-*.patch | |
| cp -v /boot/config-$(uname -r) .config | |
| # TODO(eric.cousineau): how to automate this? | |
| cat <<'EOF' | |
| When `make menuconfig` pops up TUI: | |
| General Setup > Preemption Model | |
| Select Fully Preemptible Kernel (Real-Time). | |
| Cryptographic API > Certificates for signature checking (at the very bottom of the list) | |
| > Provide system-wide ring of trusted keys | |
| > Additional X.509 keys for default system keyring | |
| Remove the “debian/canonical-certs.pem” from the prompt | |
| Save and exit | |
| EOF | |
| make olddefconfig | |
| make menuconfig | |
| make -j$(nproc) deb-pkg | |
| sudo dpkg -i ../linux-headers-*.deb ../linux-image-*.deb | |
| sudo addgroup realtime | |
| sudo usermod -a -G realtime $(whoami) | |
| cat <<'EOF' | |
| For limits: | |
| sudoedit /etc/security/limits.conf | |
| Add | |
| # https://frankaemika.github.io/docs/installation_linux.html#allow-a-user-to-set-real-time-permissions-for-its-processes | |
| @realtime soft rtprio 99 | |
| @realtime soft priority 99 | |
| @realtime soft memlock 102400 | |
| @realtime hard rtprio 99 | |
| @realtime hard priority 99 | |
| @realtime hard memlock 102400 | |
| For grub: | |
| sudoedit /etc/default/grub | |
| Change: | |
| GRUB_TIMEOUT_STYLE=menu #countdown | |
| GRUB_TIMEOUT=20 | |
| ... | |
| GRUB_CMDLINE_LINUX_DEFAULT="" # quiet splash | |
| sudo update-grub | |
| Then reboot | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment