通过内核获取config文件

有两种方法,但前提是需要配置了,才能在编译好的内核中再获取config文件。貌似是一个蛋生鸡,鸡生蛋的纠结问题。

但,有时候,我们需要配置内核运行。因此,一般是需要获得一个既有的能跑的config文件。下面介绍的这两种获取config的方法就是用于此目的的。

首先,说一下方法:
法1.在运行的内核中的/proc/config.gz 保存的便是配置文件了
法2.通过/usr/src/linux/scripts/extract-ikconfig 脚本获得一个已经编译好的内核。
这两种方法的前提是,获取内核config的内核在编译的时候,下面的两项被选中了。

CONFIG_IKCONFIG
This option enables the complete Linux kernel ".config" file
contents to be saved in the kernel. It provides documentation
of which kernel options are used in a running kernel or in an
on-disk kernel. This information can be extracted from the kernel
image file with the script scripts/extract-ikconfig and used as
input to rebuild the current kernel or to build another kernel.
It can also be extracted from a running kernel by reading
/proc/config.gz if enabled (below).
如果这一项配置了,那么通过脚本extract-ikconfig获得config文件

CONFIG_IKCONFIG_PROC

This option enables access to the kernel configuration file
through /proc/config.gz.
如果这一项配置了,那么通过运行内核获得 /proc/config.gz

评论

此博客中的热门博文

Linux/ARM Page Table Entry 属性设置分析

提交了30次才AC ---【附】POJ 2488解题报告

笔记