2011-05-23 10:49:38 +0000 2011-05-23 10:49:38 +0000
118
118
Advertisement

从当前运行的Linux系统中获取内核配置?

Advertisement

我在Linux上不小心删除了我的内核配置的.config,似乎记得有一种方法可以通过proc文件系统以某种方式检索内核配置。

现在还可以这样做吗,如果可以,怎么做?

Advertisement
Advertisement

答案 (6)

118
118
118
2011-05-23 10:51:41 +0000

根据你的系统,你会在以下任何一种中找到它。

  1. /proc/config.gz
  2. /boot/config
  3. /boot/config-$(uname -r)

还有可能是更多的地方。

57
57
57
2013-01-18 08:34:10 +0000

对于一个实际运行的内核,获取配置文件的一个方法是

cat /proc/config.gz | gunzip > running.config

或者,

zcat /proc/config.gz > running.config

然后running.config将包含运行中的linux内核的配置。

然而,只有当你的运行中的linux内核被配置为/proc/config.gz时,这才有可能。这个配置可以在

  • General setup
  • [*] Kernel .config support
  • [*] Enable access to .config through /proc/config.gz
  • /boot/

大多数发行版都没有这个配置。他们在内核包中提供内核配置文件,通常在0x6&目录下。

39
Advertisement
39
39
2015-12-11 09:51:33 +0000
Advertisement

有点晚了,但也许能帮到别人。我的电脑上没有/proc/config.gz也没有/boot/config也没有/boot/config-$(uname -r)。我必须以root身份运行modprobe configs。然后,/proc/config.gz就出现了

9
9
9
2016-09-23 16:33:31 +0000

如果你在/boot/或/proc/config.gz中找不到内核配置,你可以尝试从内核中提取这些信息。

在任何内核的源代码中都有一个提取配置的脚本,位于scripts/extract-ikconfig,把你想要的内核配置作为参数传给这个脚本。

只有在编译的内核中启用了Kernel .config support,这个解决方案才会有效。

6
Advertisement
6
6
2018-12-28 02:32:15 +0000
Advertisement

独立于发行版,你可以运行。cat /lib/modules/$(uname -r)/build/.config

Source: https://linux.die.net/man/5/proc (搜索/proc/config)。

1
1
1
2019-09-15 18:53:43 +0000

对于基于RedHat的发行版,现成内核的.config文件可以用命令cat /lib/modules/$(uname -r)/build/.config找到,在使用命令安装包kernel-devel之后就可以得到。

yum -y install kernel-devel

注意,如果是真正的Red Hat Enterprise Linux发行版,你需要启用源码库才能得到这个包。在 RHEL8 上,使用下面的命令来实现。

subscription-manager repos --enable=rhel-8-for-x86_64-baseos-source-rpms
Advertisement

相关问题

6
10
5
37
2
Advertisement