3

I am using Arch Linux with a custom kernel stored as /boot/vmlinuz-linux1. Some features I would like to have don't work in it, but there is also a /boot/vmlinuz-linux kernel where those features work. How can I retrieve the .config kernel configuration file from the second vmlinuz file in order to compare it with the configuration of the first kernel in a text editor?

3

As far as I'm aware, extracting the .config configuration file from a kernel is possible only if you've compiled it with the configuration option CONFIG_IKCONFIG (available in the configuration menu as entry General setup > Kernel .config support). Here is the documentation of that configuration option:

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).

The last sentence refers to an additional configuration option CONFIG_IKCONFIG_PROC which gives you access to the configuration of a running kernel through a file in the proc pseudo-filesystem.

If your kernel has not been compiled with CONFIG_IKCONFIG, I don't think you can retrieve its configuration easily. Otherwise, it's as simple as

gunzip /proc/config.gz > .config

if CONFIG_IKCONFIG_PROC has been selected and you're currently running your /boot/vmlinuz-linux kernel, or

scripts/extract-ikconfig /boot/vmlinuz-linux

The script extract-ikconfig is the one available along with the kernel sources, in folder scripts.

  • Yes, I have this option enabled. So I need to extract /proc/config.gz? – Dmytro Osaulenko Jul 25 '17 at 15:13
  • Yes, if there is a file /proc/config.gz, you can do gunzip /proc/config.gz > .config to retrieve the configuration. – lgeorget Jul 25 '17 at 15:14
  • Ok, I extracted it, but it seems to be the same .config file I already have from vmlinuz-linux1... – Dmytro Osaulenko Jul 25 '17 at 15:19
  • 1
    Otherwise you can use the script extract-ikconfig on vmlinuz-linux. The script is in the folder scripts in the kernel source and is also available here: stuff.mit.edu/afs/sipb/contrib/linux/scripts/extract-ikconfig. – lgeorget Jul 25 '17 at 15:22
  • 1
    Ok. I've got this .config after rebooting with second kernel. Perfect! Thank you – Dmytro Osaulenko Jul 25 '17 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.