Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Compile kernel to installable .deb package
#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
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

This comment has been minimized.

Copy link

@ashsholley88 ashsholley88 commented Feb 19, 2018

Kinda, very new at this


This comment has been minimized.

Copy link

@obeardly obeardly commented Feb 22, 2018

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.


This comment has been minimized.

Copy link

@rubo77 rubo77 commented Mar 21, 2018

Thanks a lot. I used this and updated it to a 4.x kernel:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.