debian7编译内核

时间:2021-10-02 05:00:06

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

在这里,我比较建议在发行版默认的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. Django 之 分表

    app名称为'core',基本的models.py文件内容如下: class Province(models.Model): name = models.CharField(u'省份名称',max_l ...

  2. Visual Studio 2015激活码,Visual Studio 2015密钥

    微软刚刚为开发人员奉上了最新大礼Visual Studio 2015正式版.如果你是MSDN订阅用户,现在就可以去下载丰富的相关资源.如果你指向体验一把尝尝鲜,微软也是很慷慨的. Visual Stu ...

  3. .NET程序员吧需要知道的小知识——关于数据库

    关于数据库 作为一个有“情怀的”(B格高一些的).NET开发工程师,需要多少知道一些这样的小故事. 哪怕仅仅当作一些扯淡的谈资.   1.文件型数据库(常见的) Access SQLite SQLSe ...

  4. ARM CPU与Intel x86 CPU性能比较

    Qualcomm ARM CPU与Intel x86 CPU性能比较 随着移动互联网时代的到来,Qualcomm(高通).Texas Instruments(德州仪器)等基于ARM架构的CPU受到越来 ...

  5. 科尔尼咨询公司 - MBA智库百科

    科尔尼咨询公司 - MBA智库百科 科尔尼公司简介 科尔尼管理咨询公司(A.T. Kearney)于1926年在芝加哥成立,经过80多年的发展,科尔尼咨询已发展为一家全球领先的高增值管理咨询公司,科尔 ...

  6. springMVC使用jsp:include嵌入页面的两种方式

    1.静态嵌入子页面 <%@ include file="header.jsp" %>   静态嵌入支持 jsp . html . xml 以及纯文本. 静态嵌入在编译时 ...

  7. Python学习【第26篇】:Python系列- 多线程&lpar;threading&rpar;

    线程的调用方式:threanding模块 import threading import time def sayhi(num): #定义每个线程要运行的函数 print("running ...

  8. VSTO中Word的查找方式

    VSTO中Word的查找方式 前言 使用C#在VSTO开发Word插件的过程,经常需要对文档中的内容进行查找和替换.在Word中进行文本的查找替换,和一般对纯文本的查找替换却不太一样.因为Word文档 ...

  9. XAMPP本地服务器打不开解决方案

    第一步:先开启相关服务:如图 第二步:在浏览器上输入localhost:端口号,(或127.0.0.1:端口号),按回车,就成功登陆本地服务器. =========================== ...

  10. 定义function的层级

    不知道标题拟的对不对,今天犯了个错误,图一是正确的写法. 图一 为了代码可以重复利用,我把其中两个方法独立出来,如图二. 图二 后来发现运行错误,说Gxrc未定义,百思不得其解,后来琢磨了好久,才发现 ...