You are not logged in.
Building a new kernel can be difficult and poses some risk to your system. You should be careful building new kernels on a production machine. Building a new kernel though can enable you to bypass often outdated kernels in the Debian repositories, use the newest kernels available, and compile them to match your system perfectly. This tutorial will run through the basic steps of building and installing a kernel. During the process you will encounter options allowing you to choose what modules and drivers to install.
Install packages necessary for building a kernel:
sudo apt-get install -f module-assistant build-essential
Change directory to where kernel is to be saved:
cd /usr/src/
Get your kernel (all the debian kernels you need are at Kernel.org):
sudo wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.9.tar.gz
Extract the compressed kernel (some problems can be encountered with tar -jxf, so instead you can manually open your chosen filemanager at /usr/src and simply use file-roller to extract it there). You will need to be root to extract to the /etc/src folder.
Change directory to the kernel:
cd linux-3.6.9
Make old config:
sudo make oldconfig
Here you can specify what drivers and modules you want in the kernel. If you want to be on the safe side and do not know what you need just press enter for each option.
Make the config file depending on your existing local kernel config:
sudo make localmodconfig
Here you can specify what drivers and modules you want in the kernel. If you want to be on the safe side and do not know what you need just press enter for each option.
Build the kernel:
sudo make
Install kernel modules:
sudo make modules_install
Install kernel:
sudo make install
sudo reboot
uname -a
Linux debian 3.8.0-rc1 #1 SMP PREEMPT Sat Dec 22 15:45:29 GMT 2012 x86_64 GNU/Linux
Last edited by dura (2012-12-23 14:41:34)
Offline
Thanks for the tutorial dura. Here is a very good site with lots of information on kernel configuration, and kernel "seeds" to help you optimize the configuration for your specific machine: http://www.kernel-seeds.org/ and here is how to work with a kernel seed: http://www.kernel-seeds.org/working.html
Be eggsalad to each other.
Offline
No need to compile as root, it's actually discouraged. All the steps apart from make modules install and make install should be done as regular user.
Offline
i compiled kernel 3.4.24 following above guidelines and I thought all went fine however thunar doesnt show usb sticks anymore. issue is kernel related as the kernels available in the repositiries automatically show and mount all usb sticks in thunar. any advice what went wrong with my kernel compilation?
Last edited by sakamoto (2012-12-31 05:36:24)
Offline
@sakamoto: from the gentoo handbook (http://www.gentoo.org/doc/en/kernel-config.xml)
go into your /usr/src/linux(version) folder; run
make menuconfig
then look for these
Device Drivers --->
USB support --->
<*> Support for Host-side USB
--- USB Host Controller Drivers
<*> EHCI HCD (USB 2.0) support
<*> OHCI HCD support
<*> UHCI HCD (most Intel and VIA) support
Select the HCDs present on your system, or all 3 if you are unsure.
M$ free since 2003, Linux since '96
Offline
i put this bit here just to answer any versioning questions.
[crunchbang5010:storge] ~ $ cat /proc/version
Linux version 3.7.0-1.dmz.1-liquorix-amd64 (Debian 3.7.0-1) (damentz@liquorix.net) (gcc version 4.7.2 (Debian 4.7.2-4) ) #1 ZEN SMP PREEMPT Wed Dec 26 03:29:54 UTC 2012
[crunchbang5010:storge] ~ $ cat /etc/debian_version
7.0
I think this string of command output tells the story.
[crunchbang5010:storge] /usr/src $ cd linux-3.7.1
[crunchbang5010:storge] /usr/src/linux-3.7.1 $ make menuconfig
*** Unable to find the ncurses libraries or the
*** required header files.
*** 'make menuconfig' requires the ncurses libraries.
***
*** Install ncurses (ncurses-devel) and try again.
***
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
make: *** [menuconfig] Error 2
[crunchbang5010:storge] /usr/src/linux-3.7.1 $ sudo apt-get install ncurses-devel
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ncurses-devel
[crunchbang5010:storge] /usr/src/linux-3.7.1 $
...what's going on here?
[crunchbang5010:storge] /usr/src/linux-3.7.1 $ dpkg --get-selections | grep ncurses
libncurses5:amd64 install
libncurses5:i386 install
libncursesw5:amd64 install
libncursesw5:i386 install
ncurses-base install
ncurses-bin install
ncurses-term install
[crunchbang5010:storge] /usr/src/linux-3.7.1 $ dpkg --get-selections | grep build-essential
build-essential install
[crunchbang5010:storge] /usr/src/linux-3.7.1 $ dpkg --get-selections | grep module-assistant
module-assistant install
[crunchbang5010:storge] /usr/src/linux-3.7.1 $
...maybe this is a testing bug, but the fact that OP instructs how to be able to config kernels in the first place tells me this was a choice. if it was a choice for space reasons, i don't get it, because the modules-assistant and build-essential added only ~580k and the distro install image is already too big for a cd disk.
whatever the reason, i'd like to restore this functionality. just 'use oldconfig' is not what i want, because often i just want to zero in on one flag and i don't care for oldconfig's q&a.
thanks for any help.
scary times are never dull.
Offline
^This is more a how-did than a how-to so I can't really provide support. Also, there is nothing about configuring the kernel- just how to compile it.
You are trying to use the make menuconfig method which requires ncurses. I wrote a different tutorial which went the way you have. sudo apt-get install ncurses-devel did pull in the necessary files, so I don't know why it hasn't with you. Are your repositories updated?
Compiling a kernel has nothing to do with the distro and size of the iso. I'm more interested in efficiency savings, like power consumption, which the newer kernels seem to be much better with. modules-assistant and build-essential are packages required to build a kernel; not inherent to the kernel itself as far as I am aware.
I'm running Linuxbbq so my iso size is way, way under 700mb.
Last edited by dura (2013-01-02 13:19:19)
Offline
weird. i tried to get ncurses-devel, even just now after i updated, and i don't have a source for it.
## CRUNCHBANG
## Compatible with Debian Wheezy, but use at your own risk.
deb [arch=amd64,i386] http://packages.crunchbang.org/waldorf waldorf main
#deb-src http://packages.crunchbang.org/waldorf waldorf main
## DEBIAN
deb [arch=amd64,i386] http://http.debian.net/debian wheezy main contrib non-free
#deb-src http://http.debian.org/debian wheezy main contrib non-free
## DEBIAN SECURITY
deb [arch=amd64,i386] http://security.debian.org/ wheezy/updates main
#deb-src http://security.debian.org/ wheezy/updates main
## backports
deb [arch=amd64,i386] http://backports.debian.org/debian-backports squeeze-backports main
# ignorantguru
deb [arch=amd64,i386] http://ignorantguru.github.com/debian/ unstable main
Compiling a kernel has nothing to do with the distro and size of the iso. I'm more interested in efficiency savings, like power consumption, which the newer kernels seem to be much better with. modules-assistant and build-essential are packages required to build a kernel; not inherent to the kernel itself as far as I am aware.
...i know, my point was, i've never had a system where i had to actually install the tools required to build a kernel--i've never seen anyone leave it out unless it was an embedded or wallet distro. my point was that since those two tools are so small, i'm surprised they weren't included in the default selection of packages onboard a new crunchbang install. i didn't know you were using linuxbbq, i just assumed we were talking about crunchbang.
scary times are never dull.
Offline
I'm running Sid and don't have ncurses-devel in the repo either. I wish I hadn't deleted the other tutorial because it said how I got it working with the make menuconfig you're talking about. TBH, you probably know a lot about kernel compilation than me- this isn't much of a how-to. Good luck!
Offline
@Storge
There isn't a package called ncurses-devel but there is one called ncurses-dev, which I believe is the one you want.
Offline
^Yeah, get it! That's the bugger.
Offline
thanks! ncurses-dev was what i needed.
i was searching for a fuller name -devel.
menuconfig up and running
scary times are never dull.
Offline
To be fair it is saying ncurses-devel needs to be installed:
*** Install ncurses (ncurses-devel) and try again.
Last edited by dura (2013-01-02 23:21:01)
Offline
thanks bklive and others... still busy optimizing my kernel though
http://cateee.net/lkddb/web-lkddb/ => interesting website to lookup info for all kernel config settings
just 1 question, during compiling the kernel with make command I receive some warnings now and then. is there a command to summarize all warnings after having compiled the kernel? thanks
Last edited by sakamoto (2013-01-03 21:34:22)
Offline
Thank you dura- I think you have quenched my fear of kernel compilation.
Offline
http://mapopa.blogspot.fi/2009/01/compiling-2.html
I've used the instructions on that page on my Testing system to compile 3.6.x, 3.7.0 and 3.7.1 kernels with great success. I'm perfectly happy using the old config files, just editing the Processor Family (Athlon64) to match mine made a huge difference in boot time without removing modules and stuff I don't use.
If I remember correctly, isn't there an option to make a config file that "sniffs" the modules you're using and removes obsolete ones?
Offline
do you need to copy your current config file to the new kernel directory or does make oldconfig handle that for you?
never mind just took one in anyway, don't think it matters
got everything built and installed no problems but it killed my nvidia drivers. and I can't run smxi as apt-get install linux-headers-$(uname -r). can find headers
Last edited by ManofJELLO (2013-01-10 03:59:00)
Offline
@sakamoto: from the gentoo handbook (http://www.gentoo.org/doc/en/kernel-config.xml)
go into your /usr/src/linux(version) folder; run
make menuconfig
then look for these
Device Drivers --->
USB support --->
<*> Support for Host-side USB
--- USB Host Controller Drivers
<*> EHCI HCD (USB 2.0) support
<*> OHCI HCD support
<*> UHCI HCD (most Intel and VIA) support
Select the HCDs present on your system, or all 3 if you are unsure.
And after that?
I did, make, make modules_install, make install and of course a reboot after having selected the appropriate ones for my system but that doesn't seem to have done much of a difference, USB devices still won't mount.
EDIT: Re-did the whole thing from the extraction of the .tar.gz, still no luck.
Last edited by Leonick (2013-01-13 09:36:13)
Offline
It might be worthwhile to include a post describing how to revert to the stock kernel if your self-compiled one doesn't work right for some reason.
Offline
So I've run
sudo make headers_install
but the nvidia installer can not find my headers so it can patch the module.
anyone know how to get nvidia and a custom kernel to play nice and find my version?
Offline
Could someone write a guide on how to patch a kernel?
Offline
to solve my problem, i just put the nvidia kernel source into the 3.7.2 kernel source tree and compiled the nvidia module with the kernel after changing the makefile of both the linux kernel and nvidia to know what's up. had to patch nvidia 304.64 to deal with 3.7 change though in a variable name.
just going to use this route from now on. there is another post on #! on how to build it into the kernel but haven't given that a go.
Offline
You can use smxi to remove old kernels, but it's good practice to keep one in case things go bad, perhaps. Not sure about removing them manually- but I bodged building the newest kernel for Arch the other night, and it seemed I was able to remove it by deleting the specific kernel from /etc/boot, and from /lib/modules, and then updating grub.
@dhave: to return to the stock kernel, all you have to do is choose it from grub at boot up. If you want to specify the 3.2.0.4 or whatever it is that #! comes with, then just specify that in /etc/grub putting the number of the kernel in your list as default. Check at boot- the first kernel line begins at 0.
They're also suggesting over on the Arch wiki that it is perhaps bad practice to compile kernel in /usr/src, and that instead the kernel should just be saved and compiled as normal user in your home directory.
@tlilja: the script that strips out uneccessary stuff is: sudo make localmodconfig
Last edited by dura (2013-01-24 15:12:36)
Offline
Edit: Actually, nevermind. I'm reading the .config file and flags containing 86_64 seem to be set to y.
Hello, thanks for the tutorial.
I have configured everything and compiled the kernel with all the default settings (by holding enter).
However, I don't yet want to procede to the installation, becuase I'm worried about something: how do I know whether the kernel is for 64 bit computers or 32 bit ones?
Does it even matter? Maybe it's dependent on the machine that it gets compiled on...
I have a 64 bit laptop and I have downloaded linux-3.7.4 from kernel.org...
Last edited by Yannbane (2013-01-26 17:57:00)
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat