Skip to content

Instantly share code, notes, and snippets.

@MasterJubei
Last active December 9, 2024 23:57
Show Gist options
  • Save MasterJubei/dbeda3b3e9955ea58042ef0799d6840b to your computer and use it in GitHub Desktop.
Save MasterJubei/dbeda3b3e9955ea58042ef0799d6840b to your computer and use it in GitHub Desktop.
Build mainline kernel on Ubuntu 22.04
#!/bin/bash
set -e
KERNEL_VER="6.12"
sudo apt install -y git build-essential fakeroot libncurses5-dev libssl-dev ccache dpkg-dev libelf-dev debhelper-compat libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf llvm
# Clone the kernel
mkdir -p kernelbuild
cd kernelbuild
if [ ! -d "linux-stable" ] ; then
git clone --depth=1 -b linux-$KERNEL_VER.y git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cd linux-stable
else
cd linux-stable
git pull
fi
# Build custom kernel
cp /boot/config-`uname -r` .config # copy config from current kernel
yes '' | make oldconfig
# Remove keys
sed -i 's/CONFIG_SYSTEM_TRUSTED_KEYS=.*/CONFIG_SYSTEM_TRUSTED_KEYS=""/' .config
sed -i 's/CONFIG_SYSTEM_TRUSTED_KEYRING=.*/CONFIG_SYSTEM_TRUSTED_KEYRING=""/' .config
sed -i 's/CONFIG_SYSTEM_REVOCATION_KEYS=.*/CONFIG_SYSTEM_REVOCATION_KEYS=""/' .config
make clean
make -j $(getconf _NPROCESSORS_ONLN) deb-pkg LOCALVERSION=-custom
# Install new kernel
# sudo dpkg -i ~/kernelbuild/linux-*.deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment