第一个步骤“配置内核”。

在这里,我比较建议在发行版默认的config的基础上再进行配置,这样 配置出的内核和发行版本身才会有更好的相容性。比如可以在运行“make menuconfig”之前执行命令“cp /boot/config-2.6.35-24-generic  .config”,或者在menuconfig里先把/boot/config-2.6.35-24-generic load进来。

第二个步骤是编译内核并打包的过程。通常我们可以这样下命令:

make-kpkg  --initrd --revision wwang.001 --append-to-version -20110107 kernel_image

1、--initrd选项会让make-kpkg自动帮我们生成initramfs;

2、--revision会给生成的deb文件加上一个版本信息。这个参数只是影响到文件名,如果不指定,默认会是“10.00.Custom”;

3、--append-to-version也是一种版本信息,它不仅出现在deb安装包的文件名里,也会影响到kernel的名称,比如本例中,内核更新完成之后,用“uname -r”察看会得到“2.6.36-20110107”;

4、kernel_image表示生成内核和默认模块的安装包,另外您也可以加上kernel_headers,这样make-kpkg会再生成一个内核头文件的安装包。

如果我们用普通用户来执行make-kpkg,需要加上fakeroot运行。

fakeroot make-kpkg  --initrd --revision wwang.001 --append-to-version -20110107 kernel_image

编译过程执行完毕之后,会在上层目录里生成一个deb安装包,本例中生成的安装包的文件名是“linux-image-2.6.36-20110107_wwang.001_i386.deb”。

之后我们就可以用dpkg命令或者在文件浏览器中双击安装了,安装完毕之后,直接重启就可以选择进入新的内核。

使用make-kpkg来编译内核,还有其他好处。因为我们是通过包管理器来安装新的内核,当不再需要这个内核时,就可以简单的通过dpkg命令、新立得软件包管理器或者Ubuntu软件中心来完全卸载,而不需要一个个手动删除修改。

手册的编译方法:

http://kernel-handbook.alioth.debian.org/ch-common-tasks.html#s-common-building

4.5 Building a custom kernel from Debian kernel source

This section describes the simplest possible procedure to build a custom kernel the "Debian way".  It is assumed that user is somewhat familiar with kernel configuration and build process.  If that's not the case, it is recommended to consult the kernel documentation and many excellent online resources dedicated to it.

The easiest way to build a custom kernel (the kernel with the configuration different from the one used in the official packages) from the Debian kernel source is to use the linux-source package and the make deb-pkg target.  First, prepare the kernel tree:

     # apt-get install linux-source-3.2
$ tar xjf /usr/src/linux-source-3.2.tar.bz2
$ cd linux-source-3.2

The kernel now needs to be configured, that is you have to set the kernel options and select the drivers which are going to be included, either as built-in, or as external modules.  The kernel build infrastructure offers a number of targets, which invoke different configuration frontends.  For example, one can use console-based menu configuration by invoking the command

     $ make menuconfig

Instead of menuconfig one can use config (text-based line-by-line configuration frontend) or xconfig (graphical configuration frontend).  It is also possible to reuse your old configuration file by placing it as a .config file in the top-level directory and running one of the configuration targets (if you want to adjust something) or make oldconfig (to keep the same configuration).  Note that different frontends may require different additional libraries and utilities to be installed to function properly.  For example, the menuconfig frontend requires the ncurses library, which at time of writing is provided by the libncurses5-dev package.

The build will use less disk space if the CONFIG_DEBUG_INFO option is disabled (see Disk space requirements, Section 4.2.1.1). Debuginfo is only needed if you plan to use binary object tools like crash, kgdb, and SystemTap on the kernel.

     $ scripts/config --disable DEBUG_INFO

After the configuration process is finished, the new or updated kernel configuration will be stored in .config file in the top-level directory.  The build is started using the commands

     $ make clean
$ make deb-pkg

As a result of the build, a custom kernel package linux-image-3.2.19_3.2.19-1_i386.deb (name will reflect the version of the kernel and build number) will be created in the directory one level above the top of the tree.  It may be installed using dpkg just as any other package:

     # dpkg -i ../linux-image-3.2.19_3.2.19-1_i386.deb

This command will unpack the kernel, generate the initrd if necessary (see Managing the initial ramfs (initramfs) archive, Chapter 7 for details), and configure the bootloader to make the newly installed kernel the default one.  If this command completed without any problems, you can reboot using the

     # shutdown -r now

command to boot the new kernel.

For much more information about bootloaders and their configuration please check their documentation, which can be accessed using the commands man lilo, man lilo.conf, man grub, and so on.  You can also look for documentation in the /usr/share/doc/package directories, withpackage being the name of the package involved.

debian7编译内核的更多相关文章

  1. linux内核学习之二:编译内核

    在linux内核学习系列的第一课中讲述了搭建学习环境的过程(http://www.cnblogs.com/xiongyuanxiong/p/3523306.html),环境搭好后,马上就进入到下一环节 ...

  2. 编译内核实现iptables防火墙layer7应用层过滤 (三)

    在前面的两篇文章中我们主要讲解了Linux防火墙iptables的原理及配置规则,想博友们也都知道iptables防火墙是工作在网络层,针对TCP/IP数据包实施过滤和限制,属于典型的包过滤防火墙.以 ...

  3. Debian 7.6 新编译内核 3.15.6 开机加载黑屏

    需要手动加载 fbcon 这个模块,或者编译内核的时候,Framebuffer Console support 编译进内核(后者没测试过).加在模块只要修改/etc/default/grub文件或者/ ...

  4. archlinux 传统方法编译内核linux kernel 3.3.7

    From: http://hi.baidu.com/flashgive/item/eaef6326b5eb73d3a417b662 archlinux中传统方法编译内核 1)下载内核以及补丁并解压: ...

  5. Linux下编译内核配置选项简介

    Code maturity level options代码成熟度选项 Prompt for development and/or incomplete code/drivers 显示尚在开发中或尚未完 ...

  6. Ubuntu下编译内核

    一.下载源代码和编译软件的准备 下载内核源代码:http://www.kernel.org/ 注意,点击2.6.25内核的F版,即完整版. 如果你懒得去网站点联接,运行下列命令:  代码: $cd ~ ...

  7. Linux编译内核提示'make menuconfig' requires the ncurses libraries错误

    原来使用的ubuntu 11.10系统由于误操作,导致系统崩溃,重新安装了ubuntu 11.10: 在编译内核的时候,提示如下错误: dingq@wd-u1110:~/hwsvn/2sw/1prj_ ...

  8. ubuntu10.04编译内核不显示grub菜单解决

    问题描述:        ubuntu10.04 内核版本2.6.32.28编译内核之后版本2.6.37.6,系统在编译完内核之后,不显示grub菜单 参考资料:            http:// ...

  9. Debian中编译内核

    转载: http://blog.163.com/libo_5/blog/static/156968520101016102051580/ http://hi.baidu.com/wg_wang/ite ...

随机推荐

  1. TortoiseHg简单的入门使用说明

    参考资料: 互普的 TortoiseHg使用说明_百度文库 Mercurial(Hg)基本操作 - Tim Gong - 博客园 Mercurial与TortoiseHg使用入门教程(转) - mee ...

  2. C#几种截取字符串的方法小结

    1.根据单个分隔字符用split截取例如代码如下: string st="GT123_1"; string[] sArray=st.split("_"); 即可 ...

  3. HTML 5的消息通知机制

    译文来源:http://www.ido321.com/1130.html 原文:HTML 5 Notification 译文:HTML 5 的消息通知机制 译者:dwqs HTML 5 已经被应用到W ...

  4. HDFS分布式文件系统设计思想

    HDFS设计目标 1)硬件错误是常态,数据保存需要冗余. 2)数据批量读取,Hadoop擅长数据分析而不是事务处理. 3)大规模数据集. 4)简单一致醒模型,降低系统复杂度,文件一次写入多次读取, 5 ...

  5. 最全面的 MySQL 索引详解

    什么是索引? 1.索引 索引是表的目录,在查找内容之前可以先在目录中查找索引位置,以此快速定位查询数据.对于索引,会保存在额外的文件中. 2.索引,是数据库中专门用于帮助用户快速查询数据的一种数据结构 ...

  6. html学习笔记之position

    今天主要一直看试验position的各种属性,现在记录下来以此备忘. position有四种常有属性,分别是static,fixed.absolute,relative fixed就是相对于窗口的位置 ...

  7. [iOS UI进阶 - 2.3] 彩票Demo v1.3

    A.需求 真机调试 "关于”模块 存储开关状态 打电话.发短信 应用评分 打开其他应用 cell 在iOS6 和 iOS7的适配 block的循环引用 屏幕适配 code source:   ...

  8. linux下的调试工具ltrace与strace

    ltrace能够跟踪进程的库函数调用,它会显现出哪个库函数被调用,而strace则是跟踪程序的每个系统调用. 下面是一个ltrace与strace的对比   1)系统调用的输出对比   我们用输出he ...

  9. Lua学习笔记(四):表和数组

    表 在Lua中,表(table)是十分重要的一种数据结构,实际上Lua对于复杂数据类型也仅提供了表给我们,我们通过表可以实现我们需要的大部分重要的数据结构,比如数组. table类型实现了关联数组,关 ...

  10. tomcat中的webapps

    使用IDE方便开发,使用文本编辑器建立Web工程,有助于理解工程的各个文件组成及底层原理.需搭建好服务器(常用tomcat),当然需要Java运行环境了. 一.建立JSP文件,如helloworld. ...