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

How to: Compile Linux kernel 2.6的更多相关文章

  1. Compile Linux Kernel on Ubuntu 12.04 LTS (Detailed)

    This tutorial will outline the process to compile your own kernel for Ubuntu. It will demonstrate bo ...

  2. How to compile Linux kernel in fedora 6

    前提:已裝好Fedora 6 core 2.6.18 ,在 Fedora 6 中compile linux kernel.1.下載 Fedora 6 core 2.6.18 http://www.ke ...

  3. How to compile and install Linux Kernel 5.1.2 from source code

    How to compile and install Linux Kernel 5.1.2 from source code Compiling a custom kernel has its adv ...

  4. linux kernel API and google android compile guide

    (1)linux kernel API website: http://docs.knobbits.org/local/linux-doc/html/regulator/index.html http ...

  5. CentOS7 + linux kernel 3.10.94 compile 简记

    Linux kernel 一直以其开源著称,可以自己编译选择合适的模块,针对特定的系统可以有不同的编译选项 来源 此次编译的内核版本为3.10.94,从官网www.kernel.org下载而来,自己虚 ...

  6. SourceInsight 精确导入Linux kernel源码的方法

    相信有很多人用 SourceInsight 查看 Linux Kernel 源码,但导入源码时会遇到一些问题.1.如果把整个源码树都导入进去,查看符号定义的时候,会发现有大量重复定义,很难找到正确的位 ...

  7. Linux Kernel的Makefile与Kconfig文件的语法

    https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt Introduction ------------ The c ...

  8. [中英对照]Linux kernel coding style | Linux内核编码风格

    Linux kernel coding style | Linux内核编码风格 This is a short document describing the preferred coding sty ...

  9. Linux kernel pwn notes(内核漏洞利用学习)

    前言 对这段时间学习的 linux 内核中的一些简单的利用技术做一个记录,如有差错,请见谅. 相关的文件 https://gitee.com/hac425/kernel_ctf 相关引用已在文中进行了 ...

随机推荐

  1. Java NIO学习笔记九 NIO与IO对比

    Java NIO与IO Java nio 和io 到底有什么区别,以及什么时候使用nio和io,本文做一个比较. Java NIO和IO之间的主要区别 下表总结了Java NIO和IO之间的主要区别, ...

  2. lumen5.4设置cookie

    use Illuminate\Support\Facades\Cookie; use Symfony\Component\HttpFoundation\Cookie as SCookie; //自定义 ...

  3. linux 中的命令是什么?执行命令的几种方式?如何自己创建命令?

    linux 中的命令是什么? 命令是可执行的二进制程序 执行命令的几种方式? ./test.sh                     #相对路径执行 /data/test.sh           ...

  4. Java学习笔记-IO

    IO(Input Output)流,用来处理设备之间的数据传输 IO IO概述 Java对数据的操作是通过流的方式 Java用于操作流的对象都在IO包中 流按操作数据分为两种:字节流与字符流 流按流向 ...

  5. IT架构的本质

    老僧三十年前未参禅时,见山是山,见水是水. 及至后来,亲见知识,有个入出,见山不是山,见水不是水. 而今得个休歇处,依前见山只是山,见水只是水. 参禅的三重境界在IT技术圈同样适用,初学者感叹每个产品 ...

  6. 将本地镜像上传到Docker镜像仓库

    ⒈在Docker Hub(Docker官方镜像仓库)注册自己的用户名. ⒉在Docker中使用docker login命令登录自己的用户名密码. ⒊使用docker push 镜像名称 上传本地镜像到 ...

  7. 为什么还需要应用层的Keepalive?

    既然TCP有了keepalive,应用层还需要Keepalive多此一举吗? 显然是不是的,首先协议分层思想,每层的关注点不同,TCP属于传输层,关注“通”,应用层关注是否能“用”,能“通”不一定能“ ...

  8. acm 2015北京网络赛 F Couple Trees 树链剖分+主席树

    Couple Trees Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/problemset/problem/123 ...

  9. php 取post数据的三种方式

    $_POST.$GLOBALS['HTTP_RAW_POST_DATA'].file_get_contents("php://input") 都有用来取post数据,用下来感觉大致 ...

  10. Docker——入门

    虚拟化最大区别:虚拟化技术元件,资源申请调度到其他硬件服务器: Docker是一个开源得应用容器引擎,让开发者可以打包他们得应用以及依赖包到一共可移植得容器中,然后发布到任何流行得linux机器上,也 ...