# Kernel configuration is not preserved when upgrading kernel.

## Budoka

OK. I have done enough kernel upgrades now that I can state unequivocally that my kernel config is not being saved between upgrades. I always have to go back into the new kernel and manually configure it...again, and again, and again.

I understand that it may totally be due to some mistake on my part so in another attempt to solve this problem will outline my process and hopefully someone can tell me where I am going wrong. The problem was also addressed briefly in a previous thread but was never resolved. https://forums.gentoo.org/viewtopic-t-953956-start-25-postdays-0-postorder-asc-highlight-.html

I am using https://wiki.gentoo.org/wiki/Kernel/Upgrade and https://wiki.gentoo.org/wiki/Kernel/Configuration.

So I can emerge the new kernel successfully. In most cases I am using Gentoo-Sources but in the future would like to use the hardened kernel.

I can successfully set  the symlink using 

```
eselect kernel
```

.

Then I copy the previous kernel config from 

```
...the kernel directory of the currently-running kernel:

root # cp /usr/src/oldkernel/.config /usr/src/linux/
```

 I have verified that the old config is being copied into the directory!

Then I run 

```

root # cd /usr/src/linux 

root # make oldconfig
```

Sometimes it asks me questions if new kernel options are available. I usually just select the default option.

Then I reinstall the kernel modules and compile.

I am running LUKS over LVM so use genkernel to compile that way it will build the initramfs for me.

```
genkernel --lvm --luks --menuconfig all
```

It will run and compile successfully. BUT, none of the old kernel options are preserved. Ever. I must go in and reconfigure them manually. I was initially clued in to this because since the cryptography options aren't preserved the kernel won't boot. Then when I started looking at other options that are required for my setup...and options I know I have set or tweaked none are preserved.

Can someone please tell me where I am going wrong? I tried compiling manually and then using genkernel for just the initramfs as outlined here http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=7#doc_chap3 but the end result is the same. Config options are lost.

----------

## Navar

Disclaimer: I have not used genkernel since 2010.

http://wiki.gentoo.org/wiki/Genkernel#Using_previous_kernel_configuration_while_changing_the_sources

I'd start checking from that aspect (genkernel).  In particular, if doing the old school method of cp path/priorconfig newpath/, make oldconfig, etc. seems to be working fine--especially if a simple diff of the priorconfig and newly revised shows only some changes you'd expect.  But remember, genkernel does its own way (/etc/kernels /etc/genkernel.conf, etc.)  That wiki will explain further details.

I make use of the /proc/config.gz kernel feature, so a simple cd /usr/src/linux && pwd -P && uname -r followed by zcat /proc/config.gz >.config does the job for me with the usual make oldconfig.  The former is done just to ensure where the link is actually set as most of my setups have immediately auto eselected the newly installed kernel source on a world update while some don't.  I usually forget to look into what would resolve the cause to this inconsistency.  Which later borks update requirements on other package updates from that without being prior prepared or re-eselecting active compiled kernel source  :Rolling Eyes: .  Almost seems one of the main uses for --keep-going).

----------

## eccerr0r

"works for me" ... though between different versions of the kernel, technically speaking, all bets are off.   You will still have to look through your config whether it be menuconfig or not, to make sure the options haven't changed in the new version.

Hence yes, I hate upgrading kernels.  It _is_ a PITA.  Even if I didn't have to reboot...

----------

## NeddySeagoon

Budoka,

```
genkernel --lvm --luks --menuconfig all
```

with that command genkernel overwrites your carefully updated .config with its own and drops you into menuconfig.

From memory, I've never used genkernel, there is an option to tell it to use the .config it finds in /usr/src/linux.

See the Wiki, under Kernel Configuration file used by genkernel

----------

## russK

In my experience, genkernel will save a successful .config under /etc/kernels.

----------

## Budoka

 *NeddySeagoon wrote:*   

> Budoka,
> 
> ```
> genkernel --lvm --luks --menuconfig all
> ```
> ...

 

Hmm. OK. I guess that explains it. I was using genkernel because at the moment creating an initramfs is outside of my limited skill set.

I checked the link you provided and it seems that there are two options that I could utilize.

 *Quote:*   

> --oldconfig
> 
> Issues the make oldconfig command, which attempts to collect configuration information for the system's architecture from a generic script in /usr/share/genkernel. This is a non-interactive process; no user input is entertained. Also, if --oldconfig is used in conjunction with --clean, the latter option is negated, resulting in the activation of the --no-clean option.

 

 *Quote:*   

> --kernel-config=/path/to/config-file
> 
> Specifies what alternative kernel configuration will be used, rather than the default /path/to/sources/.config file.
> 
> 

 

The 

```
--oldconfig
```

 option is a little confusing to me. When I ran "make oldconfig" on my own I had about 15 new kernel options that I was prompted to select. With the oldconfig option appended to genkernel command I wasn't prompted for anything. It indicates that "no user input is entertained" in the description but does that mean it is accepting all the default answers for new kernel options automatically?

It sounds like my best option at the moment is to continue as I have been but pass the  *Quote:*   

> --kernel-config=/path/to/config-file

  that way I can still select new kernel options when running make oldconfig. Does this sound correct?

----------

## creaker

From my experience "make oldconfig" leads to unpredictable results.

If I want to build new kernel with old .config I just copying it to new sources directory, navigating to this directory and starting "make && make modules_install" without any .config changes. If new kernel has some new options that missed in old .config - you will be asked for these options during compilation and your answers will be saved into .config automatically.

----------

## kick6

 *Budoka wrote:*   

> 
> 
> Hmm. OK. I guess that explains it. I was using genkernel because at the moment creating an initramfs is outside of my limited skill set.
> 
> 

 

What about having genkernel only build your initramfs?

```
genkernel --lvm --luks initramfs
```

should do it.

----------

## N8Fear

 *creaker wrote:*   

> From my experience "make oldconfig" leads to unpredictable results.
> 
> If I want to build new kernel with old .config I just copying it to new sources directory, navigating to this directory and starting "make && make modules_install" without any .config changes. If new kernel has some new options that missed in old .config - you will be asked for these options during compilation and your answers will be saved into .config automatically.

 

make oldconfig actually depends on an existing .config file. It'll only ask for new settings. You run it anyways actually: if you pay attention to the output of the kernel build you'll see that it runs make silentoldconfig anyways...   :Wink: 

----------

