Skip to content

Instantly share code, notes, and snippets.

@yusukeurakami
Last active August 25, 2022 01:22
Show Gist options
  • Save yusukeurakami/124aeff314465b9fde1f5af3274a879d to your computer and use it in GitHub Desktop.
Save yusukeurakami/124aeff314465b9fde1f5af3274a879d to your computer and use it in GitHub Desktop.
install_realtime_kernel
!#/usr/bin/env bash
VERSION=5.13
function downloadIfNotExists {
if [ ! -f $1 ]; then
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/$1
fi
}
if [ ! -d "$HOME/rt_kernel" ]; then
mkdir $HOME/rt_kernel
fi
cd $HOME/rt_kernel
if [ ! -d "cdn.kernel.org" ]; then
wget -m -np https://cdn.kernel.org/pub/linux/kernel/projects/rt/$VERSION/
fi
cd cdn.kernel.org/pub/linux/kernel/projects/rt/$VERSION/
downloadIfNotExists linux-$VERSION.tar.xz
downloadIfNotExists linux-$VERSION.tar.gz
downloadIfNotExists linux-$VERSION.tar.sign
tar -xzf linux-$VERSION.tar.gz
gunzip -f -k patch-$VERSION-rt1.patch.gz
cd linux-$VERSION
patch -p1 < ../patch-$VERSION-rt1.patch
# copy the current boot config (please check the version manually in case of different config)
cp -r /boot/config-$(uname -r) .config
# fix the dep-src
sudo sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list
sudo apt update && sudo apt-get build-dep linux -y
sudo apt-get install -y libncurses-dev flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf fakeroot
yes '' | make oldconfig
# set the ARCH_SUPPORTS_RT default to 'yes' to add the realtime option.
sed -i '1079s/bool/def_bool\ y/' arch/Kconfig
make menuconfig # manual interaction is required here
# check to ensure the config is same in the comment.
yes '' | make -j `nproc` deb-pkg
sudo dpkg -i ../*.deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment