How to: Compile Linux kernel 2.6

by nixcraft on September 29, 2005 · 129 comments

Compiling custom kernel has its own advantages and disadvantages. However, new Linux user / admin find it difficult to compile Linux kernel. Compiling kernel needs to understand few things and then just type couple of commands. This step by step howto covers compiling Linux kernel version 2.6.xx under Debian GNU Linux. However, instructions remains the same for any other distribution except for apt-get command.

Step # 1 Get Latest Linux kernel code

Visit http://kernel.org/ and download the latest source code. File name would be linux-x.y.z.tar.bz2, where x.y.z is actual version number. For example file inux-2.6.25.tar.bz2 represents 2.6.25 kernel version. Use wget command to download kernel source code:
$ cd /tmp
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2

Note: Replace x.y.z with actual version number.

Step # 2 Extract tar (.tar.bz3) file

Type the following command:
# tar -xjvf linux-2.6.25.tar.bz2 -C /usr/src
# cd /usr/src

Step # 3 Configure kernel

Before you configure kernel make sure you have development tools (gcc compilers and related tools) are installed on your system. If gcc compiler and tools are not installed then use apt-get command under Debian Linux to install development tools.
# apt-get install gcc

Now you can start kernel configuration by typing any one of the command:

  • $ make menuconfig - Text based color menus, radiolists & dialogs. This option also useful on remote server if you wanna compile kernel remotely.
  • $ make xconfig - X windows (Qt) based configuration tool, works best under KDE desktop
  • $ make gconfig - X windows (Gtk) based configuration tool, works best under Gnome Dekstop.

For example make menuconfig command launches following screen:
$ make menuconfig

You have to select different options as per your need. Each configuration option has HELP button associated with it so select help button to get help.

Step # 4 Compile kernel

Start compiling to create a compressed kernel image, enter:
$ make
Start compiling to kernel modules:
$ make modules

Install kernel modules (become a root user, use su command):
$ su -
# make modules_install

Step # 5 Install kernel

So far we have compiled kernel and installed kernel modules. It is time to install kernel itself.
# make install

It will install three files into /boot directory as well as modification to your kernel grub configuration file:

  • System.map-2.6.25
  • config-2.6.25
  • vmlinuz-2.6.25

Step # 6: Create an initrd image

Type the following command at a shell prompt:
# cd /boot
# mkinitrd -o initrd.img-2.6.25 2.6.25

initrd images contains device driver which needed to load rest of the operating system later on. Not all computer requires initrd, but it is safe to create one.

Step # 7 Modify Grub configuration file - /boot/grub/menu.lst

Open file using vi:
# vi /boot/grub/menu.lst

title           Debian GNU/Linux, kernel 2.6.25 Default
root            (hd0,0)
kernel          /boot/vmlinuz root=/dev/hdb1 ro
initrd          /boot/initrd.img-2.6.25
savedefault
boot

Remember to setup correct root=/dev/hdXX device. Save and close the file. If you think editing and writing all lines by hand is too much for you, try out update-grub command to update the lines for each kernel in /boot/grub/menu.lst file. Just type the command:
# update-grub
Neat. Huh?

Step # 8 : Reboot computer and boot into your new kernel

Just issue reboot command:
# reboot
For more information see:

  • Our Exploring Linux kernel article and Compiling Linux Kernel module only.
  • Official README file has more information on kernel and software requirement to compile it. This file is kernel source directory tree.
  • Documentation/ directory has interesting kernel documentation for you in kernel source tree.

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

We're here to help you make the most of sysadmin work. So, subscribe!

{ 129 comments… read them below or add one }

1 Anonymous March 7, 2006

According to the kernel documentation, the kernel should be compiled using gcc 2.95.x, with x >= 3. “apt-get install gcc” under debian gives you a recent gcc (version > 4).

Reply

2 nixcraft March 7, 2006

It works with gcc version >= 4.0.
gcc –version
gcc (GCC) 4.0.3 20060212 (prerelease) (Debian 4.0.2-9)

uname -a
Linux debian 2.6.15.4 #1 PREEMPT Fri Feb 17 20:46:04 IST 2006 i686 GNU/Linux

I have compiled above kernel using gcc 4.0.2-9. INSTALL file may be not updated.

Reply

3 Anonymous March 17, 2006

Thanks a lot Gabber Anna,
It’s works for me :-))

Reply

4 nixcraft March 17, 2006

LOL
Note sure who are you?
But you bring back some old memories…

Take care buddy :)

Reply

5 Learn Hacking March 25, 2007

any guess about boot loader?

Reply

6 debianusr August 18, 2007

After building the kernel and updating grub I’ve rebooted the new kernel successfully. Now I am wondering if this process includes updating the kernel header files in /usr/include/. If not, what is the best way to do that and should any new directories be added to ld.so.conf so I can update glibc?

Reply

7 vivek August 18, 2007

If you also upgraded kernel-devel and headers package you should get updates. No need to upgrade ld.so.conf or cache

Reply

8 Animesh October 13, 2007

Info
—–

Kernel 2.6.23 has issues with kernel headers. If you have distro’s like fedora it gonna give up some wierd fixdep.c error messages.

Some forums say you need to have 2.4 headers for compiling it. Kernel header is a huge mess scattered around and well serious debates have gone down the drain…

http://kerneltrap.org/node/6536

Reply

9 Pradeep April 30, 2008

Does this kernel support RHEL4 update 5

I am using kernel 2.6.9-55.EL can i upgade the

Reply

10 dushyant May 9, 2008

How much time does it take approximately?

Reply

11 Krishna Priya Bandyopadhyay May 15, 2008

i am trying it on mandriva 2008.i can not do “$ make menuconfig”.is there any option to do that.please help me to get out of this as soon as possible.i wonder there is no option of “make”.

Reply

12 Pothikan Suresh June 4, 2008

Priya,
To make ‘make’ work, go inside the kernel directory ie., /usr/src/. There, u can find the make file. Now, just give “$make menuconfig”. It will work…. :)

Reply

13 Krishna Priya Bandyopadhyay June 20, 2010

Thanks for ur reply.I’m working fine now with the walk through given by you…
Krishba Priya bandyopadhyay

Reply

14 Blues June 4, 2008

With 2.6 kernel there is no need for make modules. make builds kernel and modules. Have you ever read the README in kernel source directory?

Reply

15 Anil Kumar Jena June 24, 2008

It will take near about 1 to 1.30 hours. for complete
installation

Reply

16 Lin June 25, 2008

I tried make 2.6.25 in my desktop (FC5, kernel version 2.6.15), everything goes okay, but failed to boot the new kernel image with the follow error messages:

PCI: BIOS Bug: MCFG area at e0000000 is not E820-reserved
PCI: Not using MMCONFIG

Read Hat nash version 5.0.32 Starting
mount: error mounting /dev/root on /sysroot at ext3: No such device
….

In initrd.img file, I found no libata.ko or any other .ko modules are added before mkrootdev.

Is this problem caused by incorrect or even no HDD controller driver loaded? I did not see appropriate entry for libata in .config file. Do you guys have any suggestion on make it through?

Thanks.

-Lin

Reply

17 Logic July 8, 2008

About the 4th step, as the “make help” says: you do not need to do make modules again, so when using “make” it already compiles the modules.

:D

Reply

18 Ramkey October 9, 2008

Lin,

Did your problem sorted out?Thans

Reply

19 Rohit Awasthi October 10, 2008

Hi.. wt if somethin goes wrong… is there any way to get OS to its former stage, say ( backup or uninstall Kernel or something ).. or will need to install whole OS again…

Reply

20 Ravi October 31, 2008

I followed the above steps in order to compile Linux kernel “linux-2.6.27″ but when tried to boot my system from latest compiled kernel got the Kernel Panic error which says can’t find
file system /boot/root at the start.

please suggest

Reply

21 Jared November 2, 2008

This is a nice tutorial, but I have a note to make. On my installation, Ubuntu 8.04.1 64-bit, the command in Step # 6 is “mkinitramfs” instead of “mkinitrd”.

Can’t wait to try out my new kernel…

Reply

22 Abdul April 12, 2011

That helped me Thanks!!!!!!!

Reply

23 same November 2, 2008

the same thing happened to me as ravi.

Reply

24 Roman December 7, 2008

I have compiled custom kernel and I am missing in /boot directory config-2.6 file. What have I done wrong? I see config files from old kernel there. thanks in advance.

Reply

25 saga December 14, 2008

you have compiled a upstream kernel.How should i compile distribution specific kernels,like if i install fedora it has its kernel source in /usr/src/, fedora community might have added its own patches.Will the steps described in this article work for distribution specific kernels?

Reply

26 anand December 21, 2008

Except for step where you create the initrd img file, rest of the steps explained here worked fine. The Kernel version I tried was 2.6.27.10 and the linux box had ubuntu 8.10 installed.

On ubuntu if you try to use mkinitrd you might get the message “No command found”. Try using mkinitramfs instead. It worked perfectly fine.

Reply

27 Maker December 22, 2008

There is no such thing as bz3.

Reply

28 Axon December 28, 2008

It’s cool.
Thanks alot NIXTCRAFT.

Reply

29 Carnes December 29, 2008

I tried to cheat and copied over an older .config.. broke something and had to redo all the options by hand : /

Anyways, the instructions worked great with Gentoo. I had to emerge “mkinitrd” but otherwise everything went very quickly, maybe 20 min to compile everything (very short in Gentoo world).

I suggest everyone keep their old kernel and a lilo/grub option for it just incase :) Most of the problems in the comments seem to be from misconfiguring the kernel. If you aren’t sure what your hardware is or don’t have the time to run through every option. I suggest you pop in a live cd and copy “/proc/config.gz” to use as your base config (“gzip -d config.gz” will uncompress it).

If your system is already unusable, pop in a live cd and try the following as root:
“cd /”
“mkdir /mnt/fixme”
“mount /dev/ROOTDRIVE /mnt/fixme”
“mount /dev/BOOTDRIVE /mnt/fixme/boot”
“mount -t proc proc /mnt/fixme/proc”
“chroot /mnt/fixme /bin/bash”

That should put you back into your computer to compile/fix whatever.

Reply

30 benny lootens January 4, 2009

i’ve just build the 2.6.28 kernel on ubuntu 8.04 LTS and it’s working like a charm. It was required, as I had some troubles installing my 500 GB Samsung drive that was attached to a Trust eSATA IF-3300 card. Thanks for this great tutorial !!

Reply

31 Otto January 6, 2009

You don’t need make modules anymore. I compiled a few times the last days and just make && make modules_install will do.

Reply

32 Akash January 7, 2009

Following error occured during make command of compilation step for linux 2.6.23
make: *** [.tmp_vmlinux1] Error 1

Plz provide me solution for it.
Thanks
Akash

Reply

33 Akash January 7, 2009

make command error:
make: *** [.tmp_vmlinux1] Error 1
Kindly suggest solution
regards
————-
Akash

Reply

34 Pekka January 14, 2009

Hi

On Debian the kernel compile is much more straightforward than this describes.

First you of course need to take the kernel source. Then:

1. make menuconfig (or whatever you want)
2. make-kpkg –revision kernel_image
3. Install the resulting .deb package using dpkg.

The debian package management system then knows about your custom kernel and it handles all needed actions to get the kernel properly working. For example initrd is done automagically if needed.

I compile the root file system and the way to access it directly into kernel and customize the kernel sharply to the computer. That way you wont need initrd anymore :) and the machine boots quite fast, because the chipset drivers are active from wery beginning of booting.

Reply

35 komal February 7, 2009

I compiled the whole thing and then booted ..I see the updated version of fedora but when I try to run it ..it says kernal panic and doesn’t proceed any further

Reply

36 Anonymous February 17, 2009

If you have multiple CPU-kernels, you’d consider using the -j option for make, for example make -j5 , which will use 5 instance of make to built the process. This will speed up things, nice tip I got on IRC :)

Reply

37 kontinumas February 18, 2009

Hello!

got some problems while compiling new kernel using make. Error below:


{standard input}: Assembler messages:
{standard input}:745: Error: suffix or operands invalid for `mov'
{standard input}:746: Error: suffix or operands invalid for `mov'
{standard input}:950: Error: suffix or operands invalid for `mov'
{standard input}:951: Error: suffix or operands invalid for `mov'
{standard input}:1024: Error: suffix or operands invalid for `mov'
{standard input}:1025: Error: suffix or operands invalid for `mov'
{standard input}:1120: Error: suffix or operands invalid for `mov'
{standard input}:1121: Error: suffix or operands invalid for `mov'
{standard input}:1208: Error: suffix or operands invalid for `mov'
{standard input}:1220: Error: suffix or operands invalid for `mov'
make[1]: *** [arch/i386/kernel/process.o] Error 1
make: *** [arch/i386/kernel] Error 2

gcc version 4.1.2
debian etch

got some ideas? thanx

Reply

38 trevor February 19, 2009

a very good clarification about kernels,i’m impressed!

Reply

39 ondrg March 18, 2009

Thanks, it works perfectly.

Reply

40 nugga April 4, 2009

hello when i try to boot my kernel it says error file not found.

i use the following command
title Debian GNU/Linux, kernel 2.6.25 Default
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hdb1 ro
initrd /boot/initrd.img-2.6.25
savedefault
boot

im pretty noob i dont know what im doing wrong.

plzz contact me or post here.

Reply

41 nugga April 5, 2009
42 Hussain Jaffar May 5, 2009

37 ondrg, Which gcc version you used ?

Can any body tell that How to remove a previously compiled and installed kernel. So as to make space for compiling and installing a new kernel ?

Reply

43 Acevedo May 7, 2009

NIce step-by-step process, BUT Following error occured during make command of configuration step for linux 2.6.29.2
make[1]: *** [script/kconfig/dochecklxdialog] Error 1
make: *** [menuconfig] Error 2

Plz provide me solution for it.
Thanks
J.Acevedo

Reply

44 Anitha May 12, 2009

Hi… Kindly help me please… i m in serious trouble…
I m trying to install RTLinux on Linux 2.6.xx
The installation guide specified to patch the linux 2.6.xx, configure and then compile. But
i m able to proceed til the configuration of the kernel…
When i give the make command, i m coming up with errors…
Also i tried to install linux 2.6.xx without patching it with RTLinux,again i m struck up while compiling……

Kindly help please…Wil be grateful to you…

Reply

45 chindam May 29, 2009

It’s good, but i need your help to compile;boot from a flash drive and configure options such that the size of the kernel is max 5Mb(minimum application like terminal,usb…)

Reply

46 mavgh1 July 7, 2009

Great Tutorial .I have E8200 , Gigabyte EP43-DS3L kernel 2.6.18 that does not recognize coretemp,I compiled 2.6.30.1 kernel and it’s working.Thanks

Reply

47 Max Baird July 13, 2009

Hey this was great, worked for me… I had some small issues where I was missing some files like ncurses etc, but after getting them it all flowed smoothly… thanks alot again :)

Reply

48 Kousik July 20, 2009

This is nice documentation. But I think some modification is required.

Step # 6: Create an initrd image
Type the following command at a shell prompt:
# cd /boot
# mkinitrd -o initrd.img-2.6.25 2.6.25
Instead of mkinitrd I use mkinitramfs in ubuntu 9.04

Step # 7 Modify Grub configuration file – /boot/grub/menu.lst
# update-grub

update-grub is not required in ubuntu 9.04

Reply

49 Lady September 10, 2009

Can any body describe to me next: about the process0, process0 which happened in Linux kernel 2.6,
1. describe how to greate it
2. describe what they do

Reply

50 Sivakumar September 23, 2009

Hi
I am using ubuntu distribution, I like to update my kernel , my present version kernel is 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686 GNU/Linux.
i downloaded latest kernel source from kernel.org “linux-2.6.31.tar.bz2″ i followed the following steps to configure my kernel

1. i extracted the kernel source file in usr/src
2. I updated my gcc complier

root@sivakumar-desktop:/usr/src# apt-get install gcc
Reading package lists… Done
Building dependency tree
Reading state information… Done
gcc is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 228 not upgraded.

3. Then i tried to run make menuconfig, i got the following error

root@sivakumar-desktop:/usr/src# make menuconfig
make: *** No rule to make target `menuconfig’. Stop.

4. then i tried

root@sivakumar-desktop:/usr/src/linux-2.6.31# 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

Reply

51 Aks March 26, 2011

Hi there,

To resolve this issue you have to first complete all update of you system then try this

“$ sudo apt-get install libncurses5-dev”

Reply

52 saki September 28, 2009

i am also getting the same problem …….plz suggest

Reply

53 Mukesh October 11, 2009

after extracting there is some error when i configure the kernel
that error is make: *** No rule to make target ‘menuconfig’, Stop.

Reply

54 Mukesh October 11, 2009

Hello,
Can Any One Solve My Problem That Is
after extracting there is some error when i configure the kernel
that error is make: *** No rule to make target ‘menuconfig’, Stop.
plz tell me the fast it is urgent friends….
plz

Reply

55 Redd October 13, 2009

Mukesh – seems like you need to cd into the extarcted directory to run the make.

Reply

56 Redd October 13, 2009

Has anyone made a suggestion as to how to fix the kernel panic issue that was pointed to several time here? I have the same issue. After installing the new kernel and trying to boot into it, I see the kernel panic since it doesn’t see any of my drives ( “/”, “/usr”, etc). Anyideas where I went amiss?

Reply

57 Raj October 30, 2009

Hi!!
i am using Redhat 4 – kernel 2.6.9 and now i build kernel 2.7.13. it was sucessfully and after reboot i can see my new kernel in the grub.. but when i select .and proceed . i am getting the following error:

“Enforcing mode requested but no policy loaded. Halting now.
Kernel panic – not syncing: Attempted to kill init!”

please tell me wht might the problem and suggest me how to load the kenel 2.7.13..
Thanx in advance….

Reply

58 GARG November 6, 2009

problem occur on booting…
mount: unknown file system type ‘devfs’
Kernel panic – not syncing: Attempted to kill init!”

Reply

59 ben November 11, 2009

In the process make install .there are two files created in the direction /boot
Kernel image: /boot/vmlinuz-2.6.31.4-smp
Initrd image: /boot/initrd-2.6.31.4-smp
However,One file config is missed.
I update the menu.list
Then ,reboot.
On the way booting,there is no error.
but when I inter the X-window ,my keyboard and mouse doesn’t work.

Reply

60 mahdi November 24, 2009

Hi everybody,
I have followed all the steps above and succeeded in every step. But when I choose in the grub to run the 2.6.31.6 kernel I have the following message:
Unable to find a suitable fs in /proc/mounts, is it mounted ?
Use –subdomainfs to override.

I have installed the linux kernel from Ubuntu 9.10. I am not sure, but I think because I have installed ubuntu with ext4 file system, the kernel could not recognize it. The kernel is residing in /usr/src which is in the same partition as ubuntu.

Have anyone an idea out there ?
Thx,

Reply

61 bonz December 3, 2009

if you want people to do your survey you should make it accessable for us lynx users

Reply

62 Noober December 6, 2009

I need help.I follow stepbystep all is done.And but at the reboot say “error 16: inconsistent filesystem structure” what wrong whit it? My kernel is 2.6.24-16 want to upgrade kernel 2.6.31.6 plz help me thx

Reply

63 Azade December 24, 2009

Does it work for SUSE?

Reply

64 vaidya1 January 13, 2010

hey guys…….can anyone help me……….in my /boot i am not getting config file for newly compiled and installed kernel and also after successful installation of kernel.2.6.32 , i am not able to boot from this kernel as it says file system not detected , /dev/hda not detected……..and kernel panic……….

Reply

65 princelibya14 April 14, 2010

hi, bro , just try theses commend , cause i got the same problem when i used them every thing is going ok, i wish them helping u, (1. make mrproper
2.cp /boot/config-`uname -r` ./.config ,Then we run 3.make menuconfig) so these two commends use them before make menuconfig, and also do not use make only, just use (make all) . then continue as usual commend in this article, i wish them useful,
my regards,

Reply

66 BongoBongo January 16, 2010

Nice.

Came in handy as I needed to recompile kernel in order to remove KVM virtualization support. VirtualBox won’t run with KVM modules loaded.

Why am I telling you this?

Reply

67 DaVince January 28, 2010

Some of the instructions are kind of outdated on modern systems, could you perhaps update the article?

- Some systems now use GRUB 2, which doesn’t have a menu.lst.
- Modern systems tend to use mkinitramfs or yaird, not mkinitrd.

Thanks a lot for the article, though. Off to test out my new kernel.

Reply

68 ahmeds February 1, 2010

This article actually very usefull. It helped me to kompile linux kernel after my resultles
attemtions for a long period. The only issue I had was creating initrd image.
My Ubuntu 8.10 interpid (also 8.4 hardy) do not have mkinitrd command so instead
I used next steps to compile linux kernel(2.6.27.7).Here they are.
1. first copy your /boot folder to somewhere , home folder
2. go to top of your linux source tree and run(root prev required)
#make-kpkg clean && make-kpkg –initrd –revision=custom.1.0 kernel_image
and after its finished with no errors run
#dpkg -i .deb
the latest command will update your /boot also /boot/grub/menu.lst file , but this is not what
do we want , and after reboot you may find your pc not booting at all.
what do we need is new kernel and new initrd image .
our new kernel is vmlinuz-2.6.27.7 and image is initrd.img-2.6.27.7
so we have to copy these files to some temp folder , then restore our old /boot folder
from backup and copy back again our fresh kernel and image from temp folder to /boot.
to finish we need edit /boot/grub/menu.lst file.
here we can simply copy our generic boot items and make no change except names
of kernel and image to new ones. reboot and enjoy.

Reply

69 vig February 1, 2010

it really worked .. clean .. thanks .. a lot

Reply

70 Danny February 3, 2010

> Step # 2 Extract tar (.tar.bz3) file
I lol’d.

Reply

71 Anon13 March 9, 2010

Thanks! i was looking forward to use some source code for making a fake “compiling” terminal session, so i could slack on the job eventually (slow days make you wanna do something else, but boss doesnt understand the meaning of ‘I do my job so good nobody gets errors, therefore nobody needs IT support’) with the excuse that my code is compiling (thanks xkcd.com for the idea). All i do is run make on the source directory, and once im done with slackin’ i just run “make clean” to revert any changes :b

Reply

72 Tom March 14, 2010

This is after I’ve done step#2 and installed gcc.
When I use this command “make xconfig” I’m getting this error “No rule to make target”.
Any ideas on how to fix this?

Reply

73 tata1 March 16, 2010

you have to be inside linux folder,
go to yor home directory with cd und then type

pla@pla# cd /usr/src/linux
then type
pla@pla # make menuconfig or make xconfig
make sure that ncurses package is installed
all the best

Reply

74 princelibya14 April 18, 2010

hi, i have done all these steps, but i got error when i enter to my new kernel there is network to connection to internet , so can any one help me to solve this problem, cause i am not expert in fedora 10( i mean in Linux )
my regards

Reply

75 ahmeds April 22, 2010

Could you please explain in more detail your error about connection?
Can you run programs with new kernel?
And did you use config file from previous kernel or new one?

Reply

76 princelibya14 May 4, 2010

hi, bro , i am sorry, i took long time to answer on your query, so my problem is (i can not access on internet) by using wire or less card, when i run commend (iwconfig i got message no wireless extension for eth1 )so sholud i got these from last kernel on my new kernel when i configure it, and also when i search i got article i have to install package for wireless chip . my chip num is b4312, i am already installed , but there is not thing , i wish to help me, cause i waste my time on in these for month , i attempt to solve it, but nothing.plz help me as soon as u can , cause i am in rush.
my regards bro.

Reply

77 Malay Gopani May 4, 2010

Hi,
i want to add the support of portuguese font in linux. i don’t know how to add this if anyone knows then please tell me.

Reply

78 princelibya14 May 4, 2010

hi, bro, how r u? i wish to help u, u can enter on 1.system then 2.administration 3. choose language from the menu. 5 enter ur password, at last choose Portuguese language ,
i hope this info it is useful to u,
my regards.

Reply

79 Malay Gopani May 5, 2010

Hi,
Thanks,
But i want something different. I have ported linux on the device. I have done “make menuconfig” to make on the portuguese character set ,but it shows this error.
HOSTLD -static scripts/kconfig/mconf
/usr/bin/ld: cannot find -lncursesw
collect2: ld returned 1 exit status
make[1]: *** [scripts/kconfig/mconf] Error 1
make: *** [menuconfig] Error 2
i have this ncursesw library installes also.
would you help me again?

Reply

80 anon May 9, 2010

apt-get install libncurses5-dev

Reply

81 kishore May 10, 2010

Hi everybody,
I have followed all the steps above and succeeded in every step. But when I choose in the grub to run the 2.6.31.6 kernel I have the following message:
Unable to find a suitable fs in /proc/mounts, is it mounted ?
Use –subdomainfs to override.

I have installed the linux kernel from Ubuntu 9.10. I am not sure, but I think because I have installed ubuntu with ext4 file system, the kernel could not recognize it. The kernel is residing in /usr/src which is in the same partition as ubuntu.

Have anyone an idea out there ?
Thx,

Reply

82 Alex May 17, 2010

Did you maybe load ext4 as a module and not compile it directly into the kernel

Also if nothing else works I think you could bootstrap it with an initrd to make it boot in ext4

Reply

83 pankyubootha May 23, 2010

hi kishore, i think enabling SYSFS_DEPRECATED in the config file i.e. “.config” and recompiling the kernel should resolve the issue. but this may lead to udev being adversely affected. also remember to enable LBDAF in the kernel profiling segment of the .config file. good luck. PankyuBootha.

Reply

84 Jagan May 17, 2010

Hi All
Is there any changes needed during kernel configuration for USB boot support.
what are the steps required for USB boot, starting from the compilation.

any help would appreciated!!!!!
Regards
Jagan

Reply

85 ahmeds May 25, 2010

Hi Jaqan. I guess for USB boot support no kernel conf needed. Because
your kernel and initrd.img is loaded by grub from hd, USB or net.
Just copy your boot folder from HD to USB and istall grub on USB.
Restart and see what happens. Good lucks.

Reply

86 Federico June 1, 2010

I guys i have a problem when I try to generate the init image.. Using Debian 5.0 it says mkinitrd command not found.. Anyone can help me? D:
Thanks
ps: sorry for the english im italian

Reply

87 anonymous June 4, 2010

use ‘mkinitramfs’

Reply

88 ahmeds June 7, 2010

Hi Federico. I also used debian and it actually a headache to find proper initrd.img for
new kernel, as mkinitrd doesn’t work on new distrs and a lot of other stuff.
I put here the answer that found
http://www.cyberciti.biz/tips/compiling-linux-kernel-26.html/comment-page-7#comments
lucks.

Reply

89 Jeff June 9, 2010

Howdy y’all. I just wanted to ask about this process. We own a lot of RHEL/CentOS systems round here and I’m curious how the kernels built with this process will differ from the kernels shipped from the standard repositories. I’ve looked countless places for a guide to recompiling a kernel specifically with the source from those OSes, but something has always failed, or not been in the right location, etc. I’m currently building a kernel using the described process and it actually seems to be working, but I’m just wondering what functionality loss there will be.

Reply

90 Jeff June 10, 2010

Hi everyone. I just wanted to ask about this process. We own a lot of RHEL/CentOS systems round here and I’m curious how the kernels built with this process will differ from the kernels shipped from the standard repositories. I’ve looked countless places for a guide to recompiling a kernel specifically with the source from those OSes, but something has always failed, or not been in the right location, etc. I’m currently building a kernel using the described process and it actually seems to be working, but I’m just wondering what functionality loss there will be.

Reply

91 Jeff June 10, 2010

Weeell…

New kernel compiled, but either doesn’t have SATA or LVM support, as it’s failing to mount root at boot and kernel panicing. At least I got the darn thing compiled … all I really wanted to accomplish at the moment

Reply

92 Pankyu Bootha June 10, 2010

Hi Jeff, As I had said earlier, for RHEL, CentOS and such cognate systems, I have found that one has to enable SYSFS_DEPRECATED while compiling the kernel versions > 2.6.33. As for enabling SATA support, in the relevant section of the .config file one has to enable scsi/ide support while configuring the kernel. Pl first copy “.config” on desktop after uncompressing the tarball in your home directory-

$ bzip2 -dc linux-2.6.34.tar.bz2 | tar -xvf -. You can copy .config file by-

$ mv /home/jeff/linux-2.6.34/.config /home/jeff/Desktop/config.text. Then copy config.text in your home folder/directory.

Now read the config.text file carefully in gedit. you can search for SYSFS_DEPRECATED by using the interactivesearch available in the top window-bar of gedit. Also go through the scsi and ide drivers section.

To manually enable the required features do-

CONFIG SYSFS_DEPRECATED=y

Remember to uncomment the relevant by removing the ‘#’.

Affter you have thus enabled the relevant features, replace config.text to linux-2.6.34 by-

$ mv /home/jeff/Desktop/config.text /home/jeff/linux-2.6.34/.config

Now cd to linux-2.6.34 and do ‘make’
.
Any further queries are welcome. Good Luck. Pankyu Bootha

Reply

93 Rajgopal August 17, 2011

@pankyu .. Hi.. how does one enable the LVM support ?

Reply

94 Rocky July 26, 2010

Hi,

I followed this nice link for kernel compilation.Everything is done nicely.There is no any error while doing compilation process.But after step 5( Step # 5 Install kernel
# make install ) , I am not getting config file in /boot for new
kernel. I m getting systemmap,vmlinuz and initrd for new kernel.So as
per step 6 for mkinitrd, it shows already exists.

And when i rebooted machine with new kernel , getting kernel panic , /
dev/root fileystem not found.

OS: CENTOS 5.5
KERNEL : 2.6.34.1

Reply

95 ahmeds July 27, 2010

Good day Rocky. I dont know what the issue was that config file missed for new kernel at /boot folder, but you can copy it manually from source directory of the new kernel that you compiled. At step 3 you have to configure your new kernel using make menuconfig, make oldconfig , or another one of your choise. This step will do nothing else but create
.config file at the top of your source dir. As usual all files in unix that begin with dot are hidden so .config file too. Just copy it to your /boot folder using
# cp .copnfig /boot/config-2.6.x.y
Regarding kernel panic you have to specify right root filesystem.
Either the problem is with your initrd file and sometimes it is becoming real headache
to get proper initrd for new kernel that doesn’t panic.
What I do really advice just try if it will work do make oldconfig. This will config your
kernel using configuration of currently running one. And dont use make initrd but rename
and use initrd file file of your currnetly running kernel for new one.

Reply

96 Rocky July 28, 2010

Hi Ahmeds,

I followed your reply.But getting same.

Rocky

Reply

97 ahmeds July 29, 2010

Hi Rocky. It is ok if your kernel again did panic. If you want to compile kernel
just for update your current system then I can’t help you. But if you want to
compile kernel so that you could start to kernel programming then just say hello
to bulk of the problems waiting you ahead. I spent 4 month for compiling my kernel
that didn’t panic. It was 2.6.27.7 . I also learned how to configure kernel to
compile all necessary drivers built in so that kernel loaded without headache initrd.
But with 2.6.34.xx things are a little bit different. I didn’t come yet to this level but
what I may advice you is next:
1. download kernel source code of the exact version that is currently running, so that make oldconfig doesn’t complain to anything and if it does say yes.
2. try again more and more.
3. specify RIGHT ROOT filesystem. i.e. root=/dev/sda5 or root=/dev/hda2
The list of filesystems and your root filesystem you can find by df command
for example my root file system(/) mounted on /dev/sda7
john@lnx:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda7 18482044 15095664 2447528 87% /
none 504828 304 504524 1% /dev
none 509044 212 508832 1% /dev/shm

4. If these wouldn’t help try compiling necessary drivers built in. To do this do next:
1. GET list of all of your modules loaded using lsmod.
john@lnx:~$ lsmod
Module Size Used by
binfmt_misc 6587 1
rfcomm 33421 4

get module information for each module using modinfo.
john@lnx:~$ modinfo binfmt_misc | grep filename
filename: /lib/modules/2.6.32-21-generic/kernel/fs/binfmt_misc.ko
Go to your kernel source code open fs/Makefile file. Find “binfmt_misc.o” string
(Note: .o not .ko).
obj-$(CONFIG_BINFMT_MISC) += binfmt_misc.o
Then open .config file of your kernel (off course after make oldconfig ) and find
“CONFIG_BINFMT_MISC”.

CONFIG_BINFMT_MISC=m
m means compile as module. If you want this driver to be compiled built in just change m here to y and save your .config file.
CONFIG_BINFMT_MISC=y

You dont have to compile all of your drivers as built in just those which is necessary for mounting root file system, i.e. hard disk drivers, scsi if present, ext3 or 4 if they are compiled as module. It is up to you. If df prints something like
/dev/sda4 … for (root fs,/) this means you have scsi disk. /dev/hda says you have ide disk.
Huh. It is not fun at the end. Good lucks.

Reply

98 Marten July 31, 2010

Hello,

I have the exact same problem as Rocky: centos 5.5 with running kernel 2.6.18-194.3.1.el5 and I want to install 2.6.34.1. All teh steps went fine, no errors, but I had to manually copy .config into /boot/config-2.6.34.1. After reboot, same errors like Rocky and also “Volume group Volgroup00 not found” which is why / is not mounted.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
71G 21G 46G 32% /
/dev/sda1 99M 35M 59M 37% /boot
tmpfs 950M 0 950M 0% /dev/shm
# cat /boot/grub/menu.lst
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=2
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.34.1)
root (hd0,0)
kernel /vmlinuz-2.6.34.1 ro root=/dev/mapper/VolGroup00-LogVol00 rhgb quiet
initrd /initrd-2.6.34.1.img
title CentOS (2.6.18-194.8.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.8.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-194.8.1.el5.img
title CentOS (2.6.18-194.3.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.3.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-194.3.1.el5.img
Any help?:)

Reply

99 Rocky August 1, 2010

Hi,

You can resolve this error.Follow this steps.
After menuconfig.open .config file and add CONFIG_SYSFS_DEPRECATED_V2=y and then compile the kernel.Your issue wiil be resolved.If you have any query, let me know.

Rocky

Reply

100 Marten August 2, 2010

Hi Rocky,

Thanks for the help, it worked. I still get this strange error mesage:
insmod: error inserting ‘/lib/dm-region-hash.ko’: -1 File exists
but the system boots up ok, so I guess I can ignore it.
Kernel 2.6.34.1 running :D :
uname -rs
Linux 2.6.34.1

Reply

101 ragul August 16, 2010

how to recompile linux kernal?
i am working on module programming . . so i ve to disable the versoning . . can any 1 help me

Reply

102 ahmeds August 19, 2010

Hi ragul.
Pls write the command you use for compiling your module.
and also uname -r.
bye.

Reply

103 uui August 21, 2010

For step 2, I don’t think you’re suppose to do it in /usr/src when you’re installing.

Reply

104 deepak goel October 20, 2010

hiii
i am using kernel 2.6.33 but i want to compile 2.6.23
i get a error getline function conflict when i change the name of it i’ll get errors in make install command
ERROR: modinfo: could not find module garp
ERROR: modinfo: could not find module stp

plz suggest how i’ll proceed …
thnx in advance

Reply

105 goo November 21, 2010

i am using kernel linux-2.6.36-21 and i want to update it to 2.6.36
everything is ok during compiling and installing
but after reboot my system it tell me “could not load /lib/modules2.6.36/modules.dep: no such file or directory”.
any one have met this problem?
please help me, thanx

Reply

106 subhash November 26, 2010

i m using ubuntu 10.10…..completed upto step5…
In mkinitrd -o initrd.img-2.6.25 2.6.25 its giving command not found.
on trying to install initrd-tools getting the following error…..Unable to locate package initrd-tools….its very urgent….please can anyone tell what is getting wrong

Reply

107 ahmeds November 29, 2010

Good day subhash. I also had the issue with initrd.img compiling linux.
I put my solution in above comment “ahmeds February 1, 2010″.

The only mistake in this solution is #dpkg -i .deb.
prior issuing this command you have to cd ..
and then run dpkg with the deb file prodced by
#make-kpkg clean && make-kpkg –initrd –revision=custom.1.0 kernel_image

Reply

108 Hammad December 6, 2010

Hi,

I followed these instructions and managed to compile the kernel on an ubuntu virtual box. I had some issues with installing the ncurses library, and then with the mkinitrd command, but managed to resolve both of them.

However, just the make step took nearly 6 hours to complete. I thought this was OK until I read in several places that it usually takes around the order of 20 minutes or so. What might I be doing wrong?

I am running ubuntu on a virtual machine, with 512 MB RAM and 10 GB HDD space. Any help would be greatly appreciated.

Thanks!

Reply

109 anany December 24, 2010

Hi
thanks dude.. you did a rocking job..

I Remembered what youhv written somewhere.

Dont send a boy to do a Mens job..

Reply

110 Neal Anderson March 23, 2011

I found something and thought to share it with you people.

I was compiling the kernel on fedora 13 when i issued make makeconfig command i got some errors same as make*** . Thats ok , the solution is install ncurses-devel
… fine enough??

ok now shoot yum clean alll….
thats it….
now again run make makeconfig ;) here you go :D

Reply

111 deadman April 10, 2011

hey
i’m having problems while doing make for 2.6.38
its shows 44 sections mismatch(es)
i ignored it and installed the thing
but on loading its shows kernel panic
plz help

Reply

112 Tanish May 2, 2011

Hi,

I am trying to build the new kernel (2.6.38) and facing the similar issue as in the comment # 97. I followed the instructions in comment #98 but not able to fix the problem. As I start the make, the .config file is renamed to .config.old and the changes is lost. Can you help me fixing the issue? I am using CentOS 5.5.

-regards,
Tanish S.

Reply

113 vo tuan anh June 14, 2011

hi all,

I have a new PC. I want install kernel linux for it.

pls guide me create and install kernel linux [kernel.org - linux-3.0-rc3.tar.bz2]

Thank you

Reply

114 vinodsreehari July 7, 2011

Hi ,

Nicely explained. Worked for me like a charm. But I didn’t have to apply teh last two steps ,ie, creating initrd image and editing the boot loader. Those steps ahev been automatically done . Btw, I performed it in SuSe 11.3. Will it be the same in other distros also ?? Curios !!
NB: I upgraded 2.6.34 to 2.6.39 …

Reply

115 Grzeziek July 18, 2011

Kernel panic – not syncing: VFS: Unable to mount root fs ..
I’ve solved this problem by creating an initrd image with mkinitramfs function.
mkinitramfs -o initrd.img-2.6.39.3 2.6.39.3

Tried to use mkinitrd but there were no such command in Debian (even after installing kernel-package)

now everything works fine, thx for tutorial.

Reply

116 xyz July 27, 2011

hello…
i tried all the steps mentioned above….
but while using make command following error is occuring….

make: *** No rule to make target `menuconfig’. Stop.

also i have tried….

sudo apt-get install libncurses5-dev

but following error is occuring….
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Couldn’t find package libncurses5-dev
plz..plz.. reply soon….

Reply

117 vinodbhasi July 28, 2011

@XYZ

I guess you are trying to “make” outside the linux directory. change directory to linux (cd /usr/src/linux )

Reply

118 Mayank August 25, 2011

hi
I am using RHEL6 kernel version 2.6.32-71.el6.x86_64
and recompile on kernel version 3.0.3
upto this “make install” step everything going smoothly
after doing this i am not getting that three files
* System.map-3.0.3
* config-3.0.3
* vmlinuz-3.0.3
so i am not be able to make initramfs.img file with this version

so now what i can do
is there any compitablity problem…
plz help me out

Reply

119 PC September 1, 2011

Make sure you are root when you do the install. Or it will fail.

Reply

120 Tom September 9, 2011

Thanks. There’s a mistake in the “Step # 2″ title. It should be “.bz2″ not “.bz3″.

Reply

121 Vasavi September 18, 2011

Hi,
Open file using vi:
# vi /boot/grub/menu.lst

title Debian GNU/Linux, kernel 2.6.25 Default
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hdb1 ro
initrd /boot/initrd.img-2.6.25
savedefault
boot
I tried to open the menu.lst file but it is being opened in vi as a new file. So, I just updated grub and rebooted but in the boot loader list I don’t have the kernel I installed to select it. Please help.
Thanks in advance.

Reply

122 Gayathri November 14, 2011

I am facing the same problem. Any solutions ?

Reply

123 mubarik October 8, 2011

there is an error in sudo make. i am using 64 bit ubuntu 11.4.

arch/x86/kernel/entry_64.S: Assembler messages:
arch/x86/kernel/entry_64.S:1558: Error: .size expression for do_hypervisor_callback does not evaluate to a constant
make[2]: *** [arch/x86/kernel/entry_64.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2

Reply

124 Kevin Kirkwood January 4, 2012

I am having the identical problem.
have you found a solution to the problem yet?

This is something I need resolved ASAP.

If so I would really appreciate the fix.
Thanks

Thanx

Kevin

Reply

125 lambda October 16, 2011

can anyone tell me how to load an kernel image without modules and gui.
i just want to load a kernel image without any configuration.

Reply

126 bhavin December 3, 2011

hey,
I used this method to compile kernel 3.1.2 on my PC.
but I’m stuck with samples/hidraw/hid-example.c

Its is like this

samples/hidraw/hid-example.c:49: warning: unused variable ‘info’
samples/hidraw/hid-example.c:48: warning: unused variable ‘rpt_desc’
samples/hidraw/hid-example.c: In function ‘bus_str’:
samples/hidraw/hid-example.c:171: error: ‘BUS_VIRTUAL’ undeclared (first use in this function)
make[2]: *** [samples/hidraw/hid-example] Error 1
make[1]: *** [samples/hidraw] Error 2
make: *** [vmlinux] Error 2

So can anyone tell me what I should do. All other steps are going fine.

Thanks
Bhavin

Reply

127 Anisha Kaul January 20, 2012

Do,
# cd /boot/grub
# ls

Do you find menu.lst there? If yes, the do
# cat /boot/grub/menu.lst
This will show you what all is already present there.
You can open it through a text editor, and add the new and the old kernels, as shown here.

Reply

128 Amit Shaw January 20, 2012

NICE TO SEE THE DEFINE ITS AWESOME. Thanks.

Reply

129 Sakib January 20, 2012

Confirmed …Working on rhel-5.6 32bit. No need to use “mkinitrd -o initrd.img-2.6.25 2.6.25″ command.

Today I have install 2.6.30.5 kernel.

Thanks
Sakib

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 10 + 8 ?
Please leave these two fields as-is:
Are you a human being? Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: