码迷,mamicode.com
首页 > 其他好文 > 详细

debian7编译内核

时间:2014-06-14 16:17:42      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:des   http   tar   ext   com   get   

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

在这里,我比较建议在发行版默认的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编译内核,布布扣,bubuko.com

debian7编译内核

标签:des   http   tar   ext   com   get   

原文地址:http://www.cnblogs.com/lvdongjie/p/3788045.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!