100% found this document useful (3 votes)
570 views

Kernel Compile

This step by step howto covers compiling linux kernel version 2.6.xx under Debian GNU Linux. New linux user / admin find it difficult to compile kernel.

Uploaded by

amyth_316
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
570 views

Kernel Compile

This step by step howto covers compiling linux kernel version 2.6.xx under Debian GNU Linux. New linux user / admin find it difficult to compile kernel.

Uploaded by

amyth_316
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

How to: Compile Linux kernel 2.

http://www.cyberciti.biz/tips/compiling-linux-kernel...

About Forum Howtos & FAQs Low graphics Shell Scripts RSS/Feed

Training.com

Why this ad

nixcraft - insight into linux admin work


Howtos:
Linux: Find Alternative Superblocks - Dec 07, 2010
powered by

How to: Compile Linux kernel 2.6


by nixcraft on September 29, 2005 106 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 linuxx.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

1 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-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

2 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

# 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 root kernel initrd savedefault boot Debian GNU/Linux, kernel 2.6.25 Default (hd0,0) /boot/vmlinuz root=/dev/hdb1 ro /boot/initrd.img-2.6.25

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.

Training.com

Why this ad

Featured Articles: 20 Linux System Monitoring Tools Every SysAdmin Should Know 20 Linux Server Hardening Security Tips My 10 UNIX Command Line Mistakes The Novice Guide To Buying A Linux Laptop 10 Greatest Open Source Software Of 2009

3 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Top Top Top Top

5 Email Client For Linux, Mac OS X, and Windows Users 20 OpenSSH Server Best Security Practices 10 Open Source Web-Based Project Management Software 5 Linux Video Editor Software

4000+ howtos and counting! Want to read more Linux / UNIX howtos, tips and tricks? We request you to sign up for the Daily email newsletter or Weekly newsletter and get intimated about our new howtos / faqs as soon as it is released.

[email protected]
Email this to a friend Download PDF version Printable version Comment RSS feed Last Updated: Apr/17/08

Subscribe

{ 106 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, Its works for me :-)) Reply 4 nixcraft March 17, 2006
4 of 30 12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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 Ive rebooted the new kernel successfully. Now I am wondering if this process includes updating the kernel header les 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 distros like fedora it gonna give up some wierd xdep.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

5 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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 menucong.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 nd the make le. Now, just give $make menucong. It will work. :) Reply 13 Krishna Priya Bandyopadhyay June 20, 2010 Thanks for ur reply.Im working ne 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

6 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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 cant nd file system /boot/root at the start. please suggest Reply

7 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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. Cant wait to try out my new kernel Reply 22 same November 2, 2008 the same thing happened to me as ravi. Reply 23 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 24 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 25 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 ne. Reply 26 Maker December 22, 2008 There is no such thing as bz3. Reply 27 Axon December 28, 2008 Its cool.

8 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Thanks alot NIXTCRAFT. Reply 28 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 misconguring the kernel. If you arent sure what your hardware is or dont have the time to run through every option. I suggest you pop in a live cd and copy /proc/cong.gz to use as your base cong (gzip -d cong.gz will uncompress it). If your system is already unusable, pop in a live cd and try the following as root: cd / mkdir /mnt/xme mount /dev/ROOTDRIVE /mnt/xme mount /dev/BOOTDRIVE /mnt/xme/boot mount -t proc proc /mnt/xme/proc chroot /mnt/xme /bin/bash That should put you back into your computer to compile/fix whatever. Reply 29 benny lootens January 4, 2009 ive just build the 2.6.28 kernel on ubuntu 8.04 LTS and its 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 30 Otto January 6, 2009 You dont need make modules anymore. I compiled a few times the last days and just make && make modules_install will do. Reply 31 Akash January 7, 2009 Following error occured during make command of compilation step for linux 2.6.23 make: *** [.tmp_vmlinux1] Error 1

9 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Plz provide me solution for it. Thanks Akash Reply 32 Akash January 7, 2009 make command error: make: *** [.tmp_vmlinux1] Error 1 Kindly suggest solution regards Akash Reply 33 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 34 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 doesnt proceed any further Reply 35 Anonymous February 17, 2009 If you have multiple CPU-kernels, youd consider using the -j option for make, for example make -j5 , which will use 5 instance of make to built the process. This will

10 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

speed up things, nice tip I got on IRC :) Reply 36 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 37 trevor February 19, 2009 a very good clarication about kernels,im impressed! Reply 38 ondrg March 18, 2009 Thanks, it works perfectly. Reply 39 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)

11 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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 40 nugga April 5, 2009 my mail is [email protected] Reply 41 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 42 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 43 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 pleaseWil be grateful to you

12 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Reply 44 chindam May 29, 2009 Its good, but i need your help to compile;boot from a ash drive and congure options such that the size of the kernel is max 5Mb(minimum application like terminal,usb) Reply 45 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 its working.Thanks Reply 46 Max Baird July 13, 2009 Hey this was great, worked for me I had some small issues where I was missing some les like ncurses etc, but after getting them it all owed smoothly thanks alot again :) Reply 47 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 le /boot/grub/menu.lst # update-grub update-grub is not required in ubuntu 9.04 Reply 48 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 49 Sivakumar September 23, 2009

13 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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 congure 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 `menucong. 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 menucong requires the ncurses libraries. *** *** Install ncurses (ncurses-devel) and try again. *** make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1 make: *** [menuconfig] Error 2 Reply 50 saki September 28, 2009 i am also getting the same problem .plz suggest Reply 51 Mukesh October 11, 2009 after extracting there is some error when i configure the kernel that error is make: *** No rule to make target menucong, Stop. Reply 52 Mukesh October 11, 2009

14 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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 menucong, Stop. plz tell me the fast it is urgent friends. plz Reply 53 Redd October 13, 2009 Mukesh seems like you need to cd into the extarcted directory to run the make. Reply 54 Redd October 13, 2009 Has anyone made a suggestion as to how to x 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 doesnt see any of my drives ( /, /usr, etc). Anyideas where I went amiss? Reply 55 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 56 GARG November 6, 2009 problem occur on booting mount: unknown le system type devfs Kernel panic not syncing: Attempted to kill init! Reply 57 ben November 11, 2009 In the process make install .there are two files created in the direction /boot

15 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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 doesnt work. Reply 58 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 59 bonz December 3, 2009 if you want people to do your survey you should make it accessable for us lynx users Reply 60 Noober December 6, 2009 I need help.I follow stepbystep all is done.And but at the reboot say error 16: inconsistent lesystem 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 61 Azade December 24, 2009 Does it work for SUSE? Reply 62 vaidya1 January 13, 2010

16 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

hey guys.can anyone help me.in my /boot i am not getting cong le 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 le system not detected , /dev/hda not detected..and kernel panic. Reply 63 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 64 BongoBongo January 16, 2010 Nice. Came in handy as I needed to recompile kernel in order to remove KVM virtualization support. VirtualBox wont run with KVM modules loaded. Why am I telling you this? Reply 65 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 doesnt 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 66 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

17 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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 67 vig February 1, 2010 it really worked .. clean .. thanks .. a lot Reply 68 Danny February 3, 2010 > Step # 2 Extract tar (.tar.bz3) file I lold. Reply 69 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 70 Tom March 14, 2010 This is after Ive done step#2 and installed gcc. When I use this command make xcong Im getting this error No rule to make target.

18 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Any ideas on how to fix this? Reply 71 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 72 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 73 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 74 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 75 Malay Gopani May 4, 2010

19 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Hi, i want to add the support of portuguese font in linux. i dont know how to add this if anyone knows then please tell me. Reply 76 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 77 Malay Gopani May 5, 2010 Hi, Thanks, But i want something dierent. I have ported linux on the device. I have done make menucong 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 78 anon May 9, 2010 apt-get install libncurses5-dev Reply 79 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.

20 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Have anyone an idea out there ? Thx, Reply 80 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 81 pankyubootha May 23, 2010 hi kishore, i think enabling SYSFS_DEPRECATED in the cong le i.e. .cong and recompiling the kernel should resolve the issue. but this may lead to udev being adversely aected. also remember to enable LBDAF in the kernel proling segment of the .cong le. good luck. PankyuBootha. Reply 82 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 83 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 84 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

21 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

ps: sorry for the english im italian Reply 85 anonymous June 4, 2010 use mkinitramfs Reply 86 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 doesnt 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/commentpage-7#comments lucks. Reply 87 Jeff June 9, 2010 Howdy yall. I just wanted to ask about this process. We own a lot of RHEL/CentOS systems round here and Im curious how the kernels built with this process will dier from the kernels shipped from the standard repositories. Ive looked countless places for a guide to recompiling a kernel specically with the source from those OSes, but something has always failed, or not been in the right location, etc. Im currently building a kernel using the described process and it actually seems to be working, but Im just wondering what functionality loss there will be. Reply 88 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 Im curious how the kernels built with this process will dier from the kernels shipped from the standard repositories. Ive looked countless places for a guide to recompiling a kernel specically with the source from those OSes, but something has always failed, or not been in the right location, etc. Im currently building a kernel using the described process and it actually seems to be working, but Im just wondering what functionality loss there will be. Reply 89 Jeff June 10, 2010 Weeell

22 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

New kernel compiled, but either doesnt have SATA or LVM support, as its 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 90 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 .cong le one has to enable scsi/ide support while configuring the kernel. Pl first copy .cong 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 doCONFIG 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 91 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.

23 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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 92 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 doesnt 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 93 Rocky July 28, 2010 Hi Ahmeds, I followed your reply.But getting same. Rocky Reply 94 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 cant 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 didnt panic. It was 2.6.27.7 . I also learned how to congure kernel to compile all necessary drivers built in so that kernel loaded without headache initrd.

24 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

But with 2.6.34.xx things are a little bit dierent. I didnt 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 doesnt 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 wouldnt 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/Makele le. 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 95 Marten July 31, 2010 Hello,

25 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

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 ne, no errors, but I had to manually copy .cong into /boot/cong-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 96 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.

26 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Rocky Reply 97 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 98 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 99 ahmeds August 19, 2010 Hi ragul. Pls write the command you use for compiling your module. and also uname -r. bye. Reply 100 uui August 21, 2010 For step 2, I dont think youre suppose to do it in /usr/src when youre installing. Reply 101 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 conict when i change the name of it ill get errors in make install command ERROR: modinfo: could not find module garp ERROR: modinfo: could not find module stp plz suggest how ill proceed thnx in advance

27 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Reply 102 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 le or directory. any one have met this problem? please help me, thanx Reply 103 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 104 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 105 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!

28 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Reply 106 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 Leave a Comment Name * E-mail * Website

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title=""> Notify me of followup comments via e-mail.

Submit
Tagged as: command tar, compile kernel, compiling linux kernel, configuration option, configuration tool, gnu linux, how to compile linux kernel, kernel code, kernel configuration, kernel image, kernel source code, kernel v2, kernel version, latest linux kernel, linux kernel version

Previous post: Knoppix 4.0.2 DVD Released Next post: The importance of Linux partitions Sign up for our daily email newsletter:

Enter your email address

Sign Up

29 of 30

12/31/2010 11:44 AM

How to: Compile Linux kernel 2.6

http://www.cyberciti.biz/tips/compiling-linux-kernel...

Search
Find us on Facebook

nixCraft
Like 5,580 people like nixCraft.

Sebastian

Bo

Ivaylo

Ahmed

Mohamed

Vandana

Nuno

Mbah

Frantisek

Ghita

Facebook social plugin

Related Posts
Download of the day: Linux kernel 2.6.24 Programming Tutorial: How To Write a FreeBSD Kernel Module ( Driver ) Linux: How to compile program

2004-2010 nixCraft. All rights reserved. Cannot be reproduced without written permission. Privacy Policy | Terms of Service Advertise | Questions or Comments | Copyright Info | Sitemap

30 of 30

12/31/2010 11:44 AM

You might also like