# how to generate .config file from a running kernel?

## shallpion

A dump question.. assume I am running a machine but I don't have the .config file from which the kernel has been compiled. Is there any way I can generate that file from the running kernel? Thanks.

----------

## sebv

If your kernel was compiled with

```
CONFIG_IKCONFIG=y

CONFIG_IKCONFIG_PROC=y
```

you can get the config file of this kernel with 

```
zcat /proc/config.gz
```

Under Gentoo you also have http://www.gentoo.org/doc/fr/genkernel.xml, but it didn't made exactly the same kernel as the one is running.

----------

## ronmon

First, check for the file "/proc/config.gz". If that isn't there, look in any kernel source tree for the extract-ikconfig script.

/usr/src/linux/scripts/extract-ikconfig

That will pull the config from a bzImage.

----------

## shallpion

That is very helpful. Thank you guys  :Smile: 

----------

## Cripplys

Hi guys,

i tried extract-ikconfig on bzImage, but it didn't work. Script ended with this error : extract-ikconfig: Cannot find kernel config.

Could you please help me with this? I've lost previous kernel config by unmerging gentoo-sources - it was accident.   :Crying or Very sad: 

----------

## VoidMage

While I haven't used extract-ikconfig, I strongly suspect it works only on kernels built with CONFIG_IKCONFIG.

Also, unless I'm missing something, a simple unmerge shouldn't have removed the old config - not unless you've removed the old kernel directory too.

----------

## Cripplys

Well, I run "emerge --depclean" and it deleted the directory too. So now I'm trying the find a solution that helps me get back config from bzImage. But as i said, extract-ikconfig doesn't work...I think there must be some solution, but i don't know it.  :Sad: 

----------

