# is there a way to create a .config file from existing kernel

## nimar

I accidentally deleted the .conifg file from  /usr/src/linux uisng rm. Ah well, my bad. 

any way to recreate .config from exisiting bzImage or running kernel in /boot?

can't remeber all the settings and trying not to reinvent MY wheel.

Regards

-N

----------

## Logicien

Check in the /proc directory if you have a file named config.gz . It is the configuration file of the running kernel compressed with Gzip.

Some options, CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC , need to be activated in the running kernel to be able to retreive the file. You can use a script in the Linux kernel source tree, to recreate a kernel configuration from it's image when the CONFIG_IKCONFIG option have been activated:

```
CONFIG_IKCONFIG:

This option enables the complete Linux kernel ".config" file 

contents to be saved in the kernel. It provides

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

Symbol: IKCONFIG [=y]

Type  : tristate

Prompt: Kernel .config support 

   Defined at init/Kconfig:681

         Location:

         -> General setup
```

----------

## DONAHUE

if you enabled 

```
<*> Kernel .config support

[*]   Enable access to .config through /proc/config.gz
```

 /proc/config.gz will exist and can be used as you wish by 

```
zcat /proc/config.gz > /usr/src/linux/.config
```

----------

## Ant P.

If all else fails, you can run `make localyesconfig` in the kernel tree and it'll reselect all your currently in-use drivers.

----------

## nimar

Thank you! I will give the suggestions a try and get back!

----------

## nimar

 *Quote:*   

> Check in the /proc directory if you have a file named config.gz

 

Not there. Then tried  *Quote:*   

> 'make localyesconfig'

  and got:

```

linux # make localyesconfig

  HOSTCC  scripts/basic/fixdep

  HOSTCC  scripts/kconfig/conf.o

  SHIPPED scripts/kconfig/zconf.tab.c

  SHIPPED scripts/kconfig/zconf.lex.c

  SHIPPED scripts/kconfig/zconf.hash.c

  HOSTCC  scripts/kconfig/zconf.tab.o

In file included from scripts/kconfig/zconf.tab.c:2503:0:

scripts/kconfig/menu.c: In function 'get_symbol_str':

scripts/kconfig/menu.c:561:18: warning: 'jump' may be used uninitialized in this function [-Wuninitialized]

scripts/kconfig/menu.c:515:19: note: 'jump' was declared here

  HOSTLD  scripts/kconfig/conf

No config file found at scripts/kconfig/streamline_config.pl line 123.

make[1]: *** [localyesconfig] Error 2

make: *** [localyesconfig] Error 2

```

Darn! serves me right.  :Sad: 

anything else?

I hate to reinvent the wheel, but it looks like I'll have to do a better job of keeping my exsting wheels round...

----------

## Ant P.

You might need to run a normal make defconfig first.

----------

## DONAHUE

http://www.kernel-seeds.org/

----------

## nimar

While I hate it to pieces, looks like I'll have to run 'make defconfig' and move on.

Thank you all for the suggestions. I guess one of the things I WILL add is

 *Quote:*   

> 
> 
>  <*> Kernel .config support 
> 
> [*]   Enable access to .config through /proc/config.gz

 

regards

-N

----------

## NeddySeagoon

nimar,

Do you have any old kernel .config files you can use for a starting point ?

----------

