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

在这里,我比较建议在发行版默认的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. 细雨学习笔记:Jmeter测试计划最基本的元素

    测试计划-用户组下最基本的元素: 1)HTTP请求默认值 2)HTTP Cookie 管理器(有些操作需要登录后才能访问,用户信息记录在Cookie中,各请求之间就可以共享Cookie了) 3)请求S ...

  2. C++实现网格水印之调试笔记(五)—— 提取出错

    在实现提取水印的过程中,遇到了一些问题 首先还是根据论文中的思路来梳理一下整个提取流程 读入两个模型,一个原始模型ori_mesh, 一个水印模型wm_mesh. 将两个模型对齐(即放在同一个坐标系下 ...

  3. C++实现网格水印之调试笔记(二)

    整理了一下要实现的论文Watermarking 3D Polygonal Meshes in the Mesh Spectral Domain,步骤如下: 嵌入水印 à 提取水印 à 优化(网格细分) ...

  4. ACM竞赛 Java编程小结

    1.字符串的长度 String str = new String(" abcd"); int length = str.length(); 2.数组的长度.排序 2.1对于 a[] ...

  5. 《Java数据结构与算法》笔记-CH4-3用栈实现分隔符匹配

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * 利 ...

  6. http响应Last-Modified和ETag(转)

    基础知识 1) 什么是”Last-Modified”? 在浏览器第一次请求某一个URL时,服务器端的返回状态会是200,内容是你请求的资源,同时有一个Last-Modified的属性标记此文件在服务期 ...

  7. Java多线程编程模式实战指南:Active Object模式(上)

    Active Object模式简介 Active Object模式是一种异步编程模式.它通过对方法的调用与方法的执行进行解耦来提高并发性.若以任务的概念来说,Active Object模式的核心则是它 ...

  8. Java设计模式系列之桥接模式

    桥接模式(Bridge)的定义 在软件系统中,某些类型由于自身的逻辑,它具有两个或多个维度的变化,那么如何应对这种“多维度的变化”?这就要使用桥接模式 将抽象部分与它的实现部分分离,使它们都可以独立地 ...

  9. 给 TTreeView 添加复选框

    //1.引用单元 uses Commctrl ; //2.定义私有过程 procedure tvToggleCheckbox(TreeView: TTreeView;Node: TTreeNode;i ...

  10. K - 最少拦截系统

    Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不 能超过前一发的高度.某天,雷达 ...