Skip to content

Instantly share code, notes, and snippets.

@yolabingo
Last active March 5, 2022 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yolabingo/33e76c22f3ce1c12b3006ea03d45b85f to your computer and use it in GitHub Desktop.
Save yolabingo/33e76c22f3ce1c12b3006ea03d45b85f to your computer and use it in GitHub Desktop.
Build debian kernel from source

Want a cool new kernel feature but it won't show up in Debian for years?

make deb-pkg makes it easy to install a custom Linux kernel from source.

as root/sudo:

apt install build-essential libncurses5-dev gcc libssl-dev bc bison flex rsync libelf-dev
mkdir /usr/local/src/kernel
chown nonrootuser /usr/local/src/kernel
su - nonrootuser

as nonrootuser:

cd /usr/local/src/kernel
# Grab a tarball from https://www.kernel.org/
wget https://git.kernel.org/torvalds/t/linux-5.6-rc1.tar.gz
tar xf linux-5.6-rc1.tar.gz
cd linux-5.6-rc1
cp  /boot/config-$(uname -r) .config
make oldconfig # hit enter to accept defaults 
# disable module signing - adjust if you need it... https://www.kernel.org/doc/html/v4.15/admin-guide/module-signing.html
sed -ri '/CONFIG_SYSTEM_TRUSTED_KEYS/s/=.+/=""/g' .config
make -j 8 deb-pkg  # Debian has every possible thing enabled so build takes a long time
make clean # reclaim 20+ G of disk space

Note - the debug "dbg" image is huge (750M, vs 48M for standard kernel)

If you don't need it (you probably don't) just delete the linux*-dbg*.deb file rather than installing it

As root/sudo:

dpkg -i /usr/local/src/kernel/*5.6.0-rc1*.deb
reboot
# confirm kernel version with
uname -a
# uninstall older kernel versions
apt purge $( dpkg --list | grep -P -o "linux-image-\d\S+" | grep -v $(uname -r | grep -P -o ".+\d") )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment