How to: Compile Linux kernel 2.6
2014-01-18 14:01
531 查看
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.
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:
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 fileinux-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[/code]
Note: Replace x.y.z with actual version number.Type the following command:
Step # 2 Extract tar (.tar.bz3) file# tar -xjvf linux-2.6.25.tar.bz2 -C /usr/src # cd /usr/srcBefore 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.
Step # 3 Configure kernel# 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.Start compiling to create a compressed kernel image, enter:
Step # 4 Compile kernel$ make
Start compiling to kernel modules:$ make modules
Install kernel modules (become a root user, use su command):$ su - # make modules_installSo far we have compiled kernel and installed kernel modules. It is time to install kernel itself.
Step # 5 Install kernel# 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.25Type the following command at a shell prompt:
Step # 6: Create an initrd image# 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.Open file using vi:
Step # 7 Modify Grub configuration file - /boot/grub/menu.lst# vi /boot/grub/menu.lsttitle 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?Just issue reboot command:
Step # 8 : Reboot computer and boot into your new kernel# 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.
Tweet
If you would like to be kept up to date with our posts, you can follow us on Twitter, Facebook, Google+,
or even by subscribing to our RSS Feed.
Featured Articles:
30 Cool Open Source Software I Discovered in 2013
30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
Top 30 Nmap Command Examples For Sys/Network Admins
25 PHP Security Best Practices For Sys Admins
20 Linux System Monitoring Tools Every SysAdmin Should Know
20 Linux Server Hardening Security Tips
Linux: 20 Iptables Examples For New SysAdmins
Top 20 OpenSSH Server Best Security Practices
Top 20 Nginx WebServer Best Security Practices
20 Examples: Make Sure Unix / Linux Configuration Files
Are Free From Syntax Errors
15 Greatest Open Source Terminal Applications Of 2012
My 10 UNIX Command Line Mistakes
Top 10 Open Source Web-Based Project Management Software
Top 5 Email Client For Linux, Mac OS X, and Windows Users
The Novice Guide To Buying A Linux Laptop转自:http://www.cyberciti.biz/tips/compiling-linux-kernel-26.html
相关文章推荐
- HOWTO compile kernel modules for the kernel 2.6: (编译linux2.6版本内核)
- how to compile and install linux kernel
- How to Create, Compile, Load Linux LKM Loadable Kernel Modules
- How to compile Linux kernel in fedora 6
- how to compile the linux kernel
- How to: Compile Linux kernel modules
- Howto Compile and Install Linux Kernel 3.3rc / 3.2 / 3.1 / 3.0 in Ubuntu 11.10, 11.04, 10.10 and 10.
- How to compile kernel modules for the kernel 2.6
- How to Compile Linux Kernel from Source to Build Custom Kernel
- The Linux Kernel HOWTO
- HOWTO do Linux kernel development - take 3 (中文版)
- howto do linux kernel development---take3
- How-to: Update the Linux kernel
- How to get Linux Kernel Source Code of Android?
- HOWTO Remote Kernel Upgrade [出自Gentoo Linux Wiki]
- How to build a Linux kernel and flash it to the phone
- How to install kernel-2.6.***src.rpm?
- The Linux Kernel HOWTO
- Linux kernel official documents: Coding style, HOWTO, stable API nonsense, stable kernel rules
- How to: Compile Linux kernel 2.6