Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 588
user2050283 Avatar asked Feb 19 '13 13:02

user2050283


People also ask

How do I find the kernel config file?

The Linux kernel configuration is usually found in the kernel source in the file: /usr/src/linux/. config . It is not recommended to edit this file directly but to use one of these configuration options: make config - starts a character based questions and answer session.

What is boot config file?

The configuration file (/boot/grub/grub. conf), which is used to create the list of operating systems to boot in GRUB's menu interface, essentially allows the user to select a pre-set group of commands to execute.

What is proc config GZ?

/proc/config. gz is a compressed copy of the kernel configuration that was used when the kernel was build. To modify kernel configuration you have to recompile the kernel.


2 Answers

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.

like image 90
Frédéric Hamidi Avatar answered Sep 20 '22 03:09

Frédéric Hamidi


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 
like image 26
a.saurabh Avatar answered Sep 19 '22 03:09

a.saurabh