Last active
January 14, 2025 08:42
-
-
Save Avyd/8191406 to your computer and use it in GitHub Desktop.
Compile kernel to installable .deb package
This file contains 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
#Install necessary things | |
apt-get update | |
apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 build-essential -y | |
#Get the kernel | |
cd /usr/src | |
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.13.tar.xz | |
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.13.tar.sign | |
gpg --verify linux-3.13.tar.sign | |
tar xpvf linux-3.13.tar.xz | |
ln -s linux-3.13 hlinux | |
##Patch - optional | |
#cd /usr/src/linux | |
#bzip2 -dc /usr/src/patch-whatever.bz2 | patch -p1 --dry-run | |
#bzip2 -dc /usr/src/patch-whatever.bz2 | patch -p1 | |
#Configure the kernel | |
cd /usr/src/linux | |
make clean && make mrproper | |
#Save the existing config | |
cp /boot/config-`uname -r` ./.config | |
make menuconfig | |
#Load alternative config file - .config | |
#Edit config and save | |
#Build the kernel | |
make-kpkg clean | |
fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers | |
make modules | |
make modules_install | |
#Install new kernel | |
cd /usr/src | |
#Check file names before running dpkg | |
ls -l | |
dpkg -i linux-image-<VERSION>-custom_<VERSION>-custom-10.00.Custom_i386.deb | |
dpkg -i linux-headers-<VERSION>-custom_<VERSION>-custom-10.00.Custom_i386.deb | |
#Test the kernel | |
shutdown -r now | |
uname -r | |
#Notes | |
#http://www.berkes.ca/guides/linux_kernel.html | |
#http://www.howtoforge.com/kernel_compilation_ubuntu |
I just wanted to say thank you. I needed to roll a kernel today, and hadn't done that manually in over a decade. This was a huge help.
Thanks a lot. I used this and updated it to a 4.x kernel: https://gist.github.com/rubo77/cd1f8d2e3db4720b7a60aa666fd195d6
You had a typo i line 11: ln -s linux-3.13 hlinux
should be linux
whthout h
. And you don't need to install 1GB recommended latex, so better use apt-get --no-install-recommends
instead. I also made it more variable to change the kernel version in the script in only one place.
I also released it at unix.stackexchange.com
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Kinda, very new at this