user2050283
user2050283

Reputation: 570

How to get the .config from a Linux kernel image?

I have a Linux kernel image in elf format and I want to find out what .config file was used to build this kernel. When I do an objdump of the image, I see a section called kernel_config_data that contains text but does not look like the config file. Is there a way to retrieve this information?

Upvotes: 32

Views: 30009

Answers (2)

a.saurabh
a.saurabh

Reputation: 1231

You can zcat /proc/config.gz, for example:

zcat /proc/config.gz | grep 'CONFIG_PRINTK_TIME'

To dump this into the .config used in the kernel build process:

zcat /proc/config.gz > .config

Upvotes: 3

Frédéric Hamidi
Frédéric Hamidi

Reputation: 262939

Assuming your kernel was built with the IKCONFIG option, you can use the scripts/extract-ikconfig tool to extract the original .config file.

Alternately, you can boot that kernel and find the embedded configuration in /proc/config.gz.

Upvotes: 47

Related Questions