Monday, March 31, 2014

Compiling Linux Kernel Vanilla - Ubuntu/Debian way

Here is my guide on Compiling x.xx.x Vanilla Final - Ubuntu/Debian using the Debian way

This article is about compiling a kernel on Ubuntu systems. It describes how to build a custom kernel using the latest unmodified kernel sources from www.kernel.org (vanilla kernel) so that you are independent from the kernels supplied by your distribution.
Install the Required packages for building it
 
apt-get install git-core kernel-package fakeroot build-essential ncurses-dev
Then download latest kernel version
cd /usr/src
sudo su 
wget --continue http://www.kernel.org/pub/linux/kernel/v4.x/linux-4.xx.x.tar.bz2
tar jxvf linux-*.*.*.tar.bz2
cd linux-*.*.*

$ cp /boot/config-`uname -r` ./.config
$ make menuconfig

make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-vanillaice kernel_image kernel_headers
cd ..
dpkg -i linux-image-*.*.*
dpkg -i linux-headers-*.*.*
sudo shutdown -r now

you can install the headers too from /usr/src/linux-headers-3.*.*-*
in my case i can show you how the packages are named
ls *.deb
linux-image-*.*.*-vanillaice_4.4.*-vanillaice-10.00.Custom_amd64.deb
linux-headers-*.*.*-vanillaice_4.4.*-vanillaice-10.00.Custom_amd64.deb

I also created a python script http://github.com/mariuz/kernelcompile

that can be used like this
git clone https://mariuz@github.com/mariuz/kernelcompile.git
cd kernelcompile
sudo ./kernel-compile.py

10 comments:

JCarvalho said...

Hello! thanks for the tutorial.
Let me ask you a question..
How to compile in order to have a folder /source/arch/x86/include/ that is missing, I need it to install NVidia driver...
I have tried with sudo sh NVIDIA....run, but no luck, just a black screen. There is a fix but the include folder is needed.

Thanks,
Jorge

JCarvalho said...

Hello! thanks for the tutorial.
Let me ask you a question..
How to compile in order to have a folder /source/arch/x86/include/ that is missing, I need it to install NVidia driver...
I have tried with sudo sh NVIDIA....run, but no luck, just a black screen. There is a fix but the include folder is needed. please see http://slackblogs.blogspot.pt/2012/03/nvidia-drivers-29533-and-linux-kernel.html

Thanks,
Jorge

JCarvalho said...

Great post! Thanks man!

wswld said...

Thank you for the solution. I tried to do it on Debian Sid and encountered some issues. I would describe them as extendary note: http://extendary.blogspot.com/

Jean-Marc said...

Hi,

I'm getting this error:
debian/ruleset/targets/common.mk:286: *** Cannot find lguest tools.

When I try to do that:
fakeroot make-kpkg --initrd --append-to-version=-vanillaice kernel_image kernel_headers

Have you already faced this issue? Any idea where it's coming from and how to solve it?

Thanks.

Popa Adrian Marius said...

processor type and features > paravirtualized guest support > lguest guest support (uncheck)


seems to be a known bug
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=663474

Martin Atukunda said...

How about using

make deb-pkg

Unknown said...

Can you provide your compiled kernel files?

Popa Adrian Marius said...

They is already mainline ppa for ubuntu quantal if you don't want to compile it

http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.6.2-quantal/

There is a php script that downloads and istalls it for you

I didn't tested yet and it can install a non rc kernel too

http://ubuntuforums.org/showpost.php?p=12295834&postcount=26



Unknown said...

building as root is certainly not the debian way, and running wget, menuconfig also not.

but agreed, you are compiling using debians tools.