ubuntu——更新、编译、启动内核

步骤如下:

1、make mrproper

  Linux下面去编译项目之前,一般常会用make mrproper去先删除之前编译所生成的文件和配置文件,备份文件等,其中,mrproper和distclean,clean之间的区别,Linux内核源码根目录下面的makefile中,有很清晰的解释:
help:

@echo  'Cleaning targets:'

@echo  '  clean    - Remove most generated files but keep the config and'

@echo  ' enough build support to build external modules'

@echo  '  mrproper   - Remove all generated files + config + various backup files'

@echo  '  distclean   - mrproper + remove editor backup and patch files'

  mrproper到底是什么意思呢?为什么起了个这么个看起来如此诡异的名字。

  在英文wiki对Mr. Clean的解释提到了此点;

  http://en.wikipedia.org/wiki/Mr._Clean

  "make mrproper" is a command in the Linux kernel build system, used to "clean up" all files from past builds and restore the build directory to its original clean state. The reason "make mrproper" is used instead of "make mrclean" is because Linus Torvalds, the father of Linux, was familiar with the name "Mr. Proper" as this is the brand widely known in Europe."

  总的来说,就是:首先,我们要知道的是make mrproper想要做的事情是,清理旧的编译生成的文件及其他配置等文件,所以,相当于Clean,即我们在现实世界中用清洁剂去清洁卫生,清理旧的, 不再需要的,脏东西。而现实世界中,保洁(P&G)公司的,有一个清洁产品方面的品牌,在美国叫做Mr.Clean,在欧洲叫做 Mr.Proper,所以编译之前的清理旧东西的命令,原先是用的make mrclean,即make Mr.Clean。只是后来被Linux之父Linus Torvalds改成了make mrproper,即make Mr.Proper。所以,现在就变成了用make mrproper来清理之前的东西了。

  但是,它更深层次的清除你上次编译内核的东西,就是说比make clean还要厉害! 

  make mrproper在Readme中的解释如下:

  Make sure you have no stale .o files and dependencies lying around:

2、cp /boot/config-`uname -r` .config

  编译内核时的配置文件。

  /boot/config-`uname -r`为当前内核编译时的配置文件,因为更新内核时是在同一台机器上,所以编译新内核时的配置文件与旧的相同。

3、sudo apt-get install libncurses5-dev

  Ncurses 提供字符终端处理库,包括面板和菜单。

  编译内核时的辅助编译工具,提供选项菜单面板。

4、make menuconfig

  根据.config生成Makefile。

  图形化的内核配置。解释如下:

  •   #make config(基于文本的最为传统的配置界面,不推荐使用)
  •   #make menuconfig(基于文本选单的配置界面,字符终端下推荐使用)

  注意:使用make menuconfig 需要安装ncurses( sudo apt-get install ncurses-dev) 

  •   #make xconfig(基于图形窗口模式的配置界面,Xwindow下推荐使用)

  注意:如果要用make xconfig,则要先安装libqt3-compat-headers( sudo apt-get install libqt3-compat-headers)

  •   #make oldconfig(如果只想在原来内核配置的基础上修改一些小地方,会省去不少麻烦) 

      目的都是生成一个.config文件,这三个命令中,make xconfig的界面最为友好,如果你可以使用Xwindow,你就用这个好了,这个比较方便,也好设置。如果你不能使用Xwindow,那么就使用make menuconfig好了。界面虽然比上面一个差点,总比make config的要好多了。 选择相应的配置时,有三种选择,它们分别代表的含义如下: 

  Y--将该功能编译进内核 

  N--不将该功能编译进内核 

  M--将该功能编译成可以在需要时动态插入到内核中的模块 。

5、在菜单中选择需要的配置

6、make

  根据Makefile编译内核,得到内核镜像文件。

7、make modules_install

  安装植入模块。

8、make install

  安装植入内核。

9、reboot

  重启系统后,uname -r就可以看到现在是更新过后的内核。

原文地址:https://www.cnblogs.com/ISeeIC/p/3631004.html