When talking with a linux user you might have heard him referring to ‘kernel compiling’ as a cool thing he would like to do but a bit frustrating also. The Linux kernel is the heart of Linux OS. So kernel compiling is a serious thing to mess with.
Before compiling your own kernel you should know really well what your computer’s hardware is. This way you can exclude from the kernel all the modules and drivers you don’t need and thus making your kernel smaller and your system faster!
Here I’ll show you how to compile a kernel of the 2.6.x series. The whole procedure consists of the following steps
| http://www.kernel.org/pub/linux/kernel/v2.6/ # wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x-new.tar.gz # cp linux-x-new.tar.gz /usr/src # cd /usr/src # tar zxf linux-x-new.tar.gz # cp linux-x-old/.config linux-x-new/.config # cd linux-x-new # make oldconfig # make xconfig or # make menuconfig # make # make modules_install # make install # reboot |
Pretty simple, isn’t it?!
Now let’s give some more specific details on what the above commands do. You should be root when running these commands.
| http://www.kernel.org/pub/linux/kernel/v2.6/ |
First go to the above link and find the latest kernel version. Lets assume that it is linux-x-new.tar.gz
| # wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x-new.tar.gz |
Download it using wget
| # cp linux-x-new.tar.gz /usr/src |
And copy it under /usr/src
| # cd /usr/src |
Go to this directory
| # tar zxf linux-x-new.tar.gz |
And extract the kernel from the compressed file. This command will create a new folder called linux-x-new
| # cp linux-x-old/.config linux-x-new/.config |
This command copies all the configuration from your old kernel to the new one. This way you have a good starting point and you don’t have to configure everything from the beginning!
| # cd linux-x-new |
Now go to the directory that contains your new kernel
| # make oldconfig |
And get your old configuration
| # make xconfig or # make menuconfig |
If you have qt libraries installed on your system run # make xconfig. This is the graphical configuration system through which you will make all the necessary changes in your kernel. If you have only ncurses installed you may run # make menuconfig
| # make |
When you have configured everything run make to start compiling your kernel
| # make modules_install |
Then run make modules_install to install your new modules created above.
| # make install |
And finally create all the necessary files under /boot and also configure grub to include your new kernel
| # reboot |
Reboot and from grub choose the new kernel! If anything goes wrong it means you have made a mistake in the kernel configuration. Boot in with your old kernel and run again make xconfig to do the appropriate changes.
Well, it is simple, eh? ;)
Add this page to your favorite Social Bookmarking websites
Trackback(0)
TrackBack URI for this entryComments (11)
Subscribe to this comment's feed...
Thanks for your very usefull guides!
I am new in linux and use your gudes very often!
Currently I use Fedora 9 (Kernel V.2.6.26.5-45.fc9.x86_64)
and wanted to recompile it using this guid... but I stuck here>
# cp linux-x-old/.config linux-x-new/.config
my result:
[root@UNCLEZ src]# cp linux-2.6.26.5-45.fc9.x86_64/.config linux-2.6.26/.config
cp: cannot stat `linux-2.6.26.5-45.fc9.x86_64/.config': No such file or directory
Any ideas?
...
ls -a /usr/src/linux-2.6.26.5-45.fc9.x86_64/
the output...
Thanks for your response.
Here is the output:
[zz@UNCLEZ ~]$ ls -a /usr/src/linux-2.6.26.5-45.fc9.x86_64/
ls: cannot access /usr/src/linux-2.6.26.5-45.fc9.x86_64/: No such file or directory
...
For any other questions please use our Forum. It's easier answering questions there.
...
It has been a long time since I last compiled my kernel! Now I am just using the ones provided through my distribution's repositories.
this is the a damm piece of info
i just fellowed urs steps .....& was able to compile the kernel in less time compaired to the rpm style of building the kernel
thnaks a lot buddy
Patches?
Apologies for the late post, but just stumbled across. How does one incorporate distro-specific kernel patches while recompiling a given kernel (i.e. those contained in the Fedora kernel source rpm)? I just need to tweak a couple kernel settings and want to avoid unnecessarily altering other aspects of the distro.
Thanks!
Write comment