Beruflich Dokumente
Kultur Dokumente
1 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
Home
Free eBook
Start Here
Contact
About
Like
66
Tweet
Linux kernel is the life force of all Linux family of operating systems including Ubuntu,
CentOS, and Fedora.
For most part, you dont need to compile the kernel, as it is installed by default when
you install the OS. Also, when there is a critical update done to the kernel, you can use
yum, or apt-get to update the kernel on your Linux system.
However you might encounter certain situation, where you may have to compile kernel
from source. The following are few situation where you may have to compile Kernel on
your Linux system.
To enable experimental features that are not part of the default kernel.
To enable support for a new hardware that is not currently supported by the default
kernel.
To debug the kernel
Or, just to learn how kernel works, you might want to explore the kernel source
code, and compile it on your own.
In this tutorial, well explain how to compile Linux kernel from source.
Also, please note that if you just want to compile a driver, you dont need to compile the
kernel. You need only the linux-headers package of the kernel.
2 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
# cd linux-3.9.3
# make menuconfig
The make menucong, will launch a text-based user interface with default conguration
options as shown in the gure. You should have installed libncurses and libncursesdevel packages for this command to work.
3 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
We will use the default cong provided by the kernel. So select Save and save the
cong in the le name .cong.
The following is a sample of the .cong le:
CONFIG_MMU=y
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_HWEIGHT=y
At this point, you should see a directory named /lib/modules/3.9.3/ in your system.
The make install command will create the following les in the /boot directory.
4 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
Since, in grub.cfg, the new kernel is added as default boot, the system will boot from the
new kernel. Just in case if you have problems with the new kernel, you can select the old
kernel from the grub menu during boot and you can use your system as usual.
Once the system is up, use uname command to verify that the new version of Linux
kernel is installed.
$ uname -r
3.9.3
25
Tweet
Like
66
5 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
Tags: CentOS Compile Kernel, Compiling Kernel, Compiling Kernel Modules, Debian
Compile Kernel, Fedora Compile Kernel, Install Linux Kernel, Kernel Cong File, Linux
Kernel Cong, Linux Kernel Modules, Linux Kernel Source, Recompile Linux Kernel,
Ubuntu Compile Kernel
{ 18 comments read them below or add one }
1 Anthony June 13, 2013 at 6:10 am
Nowdays, all computers CPU are multicore, multithreaded. It would have been
nice to show make -j N with N the number of (core * thread-by-core) to help built
faster otherwise it can take forever!
nu said!
2 Deepak June 13, 2013 at 8:36 am
one more reason to compile a kernel is if we want to install latest kernel whose rpm
is not available yet.
3 me June 13, 2013 at 8:38 am
You make no mention of things like
make localmodcong
to avoid making hundred of unnecessary modules.
Maybe I dont want gcc on every linux pc, how can an rpm be made.
Your making the compile extremely slow by not including -j # representing the
number of concurrent compiles.
This is guide is far from complete.
4 Feiticeir0 June 13, 2013 at 8:50 am
6 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
Or if you dont want all the bloatware that comes with predened kernels from your
distro although it packs security and enhancement patches.
5 me June 13, 2013 at 8:57 am
/proc/cong.gz
If present, this is the current running cong le compressed.
6 Jalal Hajigholamali June 13, 2013 at 8:59 am
Hi,
Thanks a lot,
useful article
7 Koratsuki June 13, 2013 at 9:25 am
@Deepak: Or use new options/drivers/congs unavailable on older kernels Nice
article
8 Bob June 13, 2013 at 10:42 am
Nice article. Thanks
9 John Yost June 13, 2013 at 1:13 pm
I believe make install updates the lilo.cong le not grub.cfg
10 Jim Lee June 13, 2013 at 3:28 pm
I used to do steps #4 and #5 for my Debian (Sid) install but sometimes found that I
needed the associated headers to satisfy dependencies for things I wanted to install
or recompile afterward (like VMWare player, for example); many times those
headers were not available, especially if I was compiling a bleedding-edge kernel.
These days I just use make deb-pkg instead. This takes care of the compile and
produces the linux-rmware-image, linux-image, linux-headers and linuxlibc-dev .deb packages. A subsequent dpkg -i *.deb installs these packages and
satises those dependencies.
11 Daniel June 13, 2013 at 3:49 pm
Very nice article. But you could have given a warning like This may take some
time, so dont do it right before you are going to bed Now Ill have to wait!
12 chris June 15, 2013 at 12:09 pm
hi i tried to install kernel-3.9.0 but it got interupted during compiling (after
entering the make command).it logged out by itself.so i logged in and assuming
that the compiling was over i proceded to compile the modules and install it .
when i entered the make install command it requested to redo the make make
process.and then install.
Monday 10 March 2014 11:26 PM
7 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
after rebooting the resolution changed and the keyboard and mouse stopped
working.
im currently using the old kernel and i would like to delete the one that i installed.
13 Ethan June 16, 2013 at 3:07 am
Good to see the concise explaination by Lakshmanan.
14 Chad June 19, 2013 at 11:24 am
@chris
Theres no auto pilot here.
And customizing kernel is not for the faint of heart , you should read quite a lot
before you actually start customizing it.
15 Anonymous July 1, 2013 at 10:18 am
make bzImage;
make modules && make modules_install
16 Gomathi August 22, 2013 at 5:45 am
The BEST!
17 YektaPardaz October 4, 2013 at 10:36 am
Thanks for nice article.
But I have a question. How can I cong kernel source for best performance on my
vps? I mean is there a way to remove unnecessary modules of kernel before
building it? Modules like new VGA support, new other le-system support(other
than ext3 and ext4), .. . Im looking for ways to make my custom kernel as small
and fast as possible.
18 cybernard October 7, 2013 at 6:21 am
make localmodcong
that eliminates all modules not currently loaded in memory.
Leave a Comment
Name
E-mail
Website
8 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
Submit
Previous post: How to Write C++ Virtual Functions with Examples
Next post: How to View and Change DELL Server BIOS Settings
RSS | Email | Twitter | Facebook | Google+
Search
COURSE
Linux Sysadmin CentOS 6 Course - Master the Tools, Congure it Right, and
be Lazy
EBOOKS
Linux 101 Hacks 2nd Edition eBook - Practical Examples to Build a
Strong Foundation in Linux
Bash 101 Hacks eBook - Take Control of Your Bash Command Line and Shell
Scripting
Sed and Awk 101 Hacks eBook - Enhance Your UNIX / Linux Life with Sed and
Awk
Vim 101 Hacks eBook - Practical Examples for Becoming Fast and Productive
in Vim Editor
Monday 10 March 2014 11:26 PM
9 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
POPULAR POSTS
12 Amazing and Essential Linux Books To Enrich Your Brain and Library
50 UNIX / Linux Sysadmin Tutorials
50 Most Frequently Used UNIX / Linux Commands (With Examples)
How To Be Productive and Get Things Done Using GTD
30 Things To Do When you are Bored and have a Computer
Linux Directory Structure (File System Structure) Explained with Examples
Linux Crontab: 15 Awesome Cron Job Examples
Get a Grip on the Grep! 15 Practical Grep Command Examples
Unix LS Command: 15 Practical Examples
15 Examples To Master Linux Command Line History
Top 10 Open Source Bug Tracking System
Vi and Vim Macro Tutorial: How To Record and Play
Mommy, I found it! -- 15 Practical Linux Find Command Examples
15 Awesome Gmail Tips and Tricks
15 Awesome Google Search Tips and Tricks
RAID 0, RAID 1, RAID 5, RAID 10 Explained with Diagrams
Can You Top This? 15 Practical Linux Top Command Examples
Top 5 Best System Monitoring Tools
Top 5 Best Linux OS Distributions
How To Monitor Remote Linux Host using Nagios 3.0
Awk Introduction Tutorial 7 Awk Print Examples
How to Backup Linux? 15 rsync Command Examples
The Ultimate Wget Download Guide With 15 Awesome Examples
Top 5 Best Linux Text Editors
Packet Analyzer: 15 TCPDUMP Command Examples
The Ultimate Bash Array Tutorial with 15 Examples
3 Steps to Perform SSH Login Without Password Using ssh-keygen &
ssh-copy-id
Unix Sed Tutorial: Advanced Sed Substitution Examples
UNIX / Linux: 10 Netstat Command Examples
The Ultimate Guide for Creating Strong Passwords
6 Steps to Secure Your Home Wireless Network
Monday 10 March 2014 11:26 PM
10 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
CATEGORIES
Linux Tutorials
Vim Editor
Sed Scripting
Awk Scripting
Bash Shell Scripting
Nagios Monitoring
OpenSSH
IPTables Firewall
Apache Web Server
MySQL Database
Perl Programming
Google Tutorials
Ubuntu Tutorials
PostgreSQL DB
Hello World Examples
C Programming
C++ Programming
DELL Server Tutorials
Oracle Database
VMware Tutorials
Ramesh Natarajan
Follow
Support Us
Support this blog by purchasing one of my ebooks.
Bash 101 Hacks eBook
Monday 10 March 2014 11:26 PM
11 of 11
http://www.thegeekstu.com/2013/06/compile-linux-kernel/
Contact Us
Email Me : Use this Contact Form to get in touch me with your comments,
questions or suggestions about this site. You can also simply drop me a line to say
hello!.
Follow us on Google+
Follow us on Twitter
Become a fan on Facebook
Copyright 20082014 Ramesh Natarajan. All rights reserved | Terms of Service