# .config overwritten?

## k0OA1

Hi   :Very Happy: 

I am experiencing an issue where the .config file I'm using is overwritten just before compilation.

I used eselect kernel to specify the latest gentoo-sources (linux-5.3.11-gentoo)

Next, I copied my old config to /usr/src/linux/

Ran

```
sudo genkernel --menuconfig all --makeopts=-j6
```

Loaded the previous config and saved it to .config

And compiled..

The result is:

```
* Gentoo Linux Genkernel; Version 4.0.0_beta20

* Using genkernel configuration from '/etc/genkernel.conf' ...

* Running with options: --menuconfig all --makeopts=-j6

* Working with Linux kernel 5.3.11-gentoo-x86_64 for x86_64

* Using kernel config file '/usr/share/genkernel/arch/x86_64/generated-config' ...

* 

* Note: The version above is subject to change (depends on config and status of kernel sources).

* kernel: >> Initializing ...

*         >> Previous config backed up to .config--2019-11-14--20-45-06.bak

*         >> Running 'make mrproper' ...

*         >> Running 'make oldconfig' ...

*         >> Invoking menuconfig ...

*         >> Re-running 'make oldconfig' due to changed kernel options ...

*         >> Compiling 5.3.11-gentoo-x86_64 bzImage ...

^Z

```

Where "Compiling 5.3.11-gentoo-x86_64 bzImage" should have the appended version string I set in menuconfig. But it doesn't.

When I check .config in /usr/src/linux/ , it has reverted to a default configuration.

I have tried recompiling the current kernel with a previously working config, but the same error occurs.

I have also tried changing various genkernel options with no joy.

Thank you for reading, I hope you can offer me some guidance.

Kind Regards,

Al

----------

## OldTango

 *k0OA1 wrote:*   

> Hi  
> 
> I am experiencing an issue where the .config file I'm using is overwritten just before compilation.
> 
> The result is:
> ...

 I manually build all my own kernels and have never used genkernel so I am not sure how it works. Based on your output, your setting "make mrproper" which should clean all objects and .configs from your kernel sources.  Are you sure this is what you want?

From the Gentoo Genkernel Wiki: *Quote:*   

> --[no-]mrproper
> 
>     Activates (or deactivates) the make mrproper command before kernel compilation. Like the make clean command listed above, make mrproper removes all object files and dependencies from the kernel's source tree. However, any previous configuration files (in /path/to/sources/.config or /path/to/sources/.config.old) will also be purged from the kernel's source tree. If it is undesirable that the kernel's .config file keeps disappearing, be sure to disable this option!

 

Best Tango.....  :Wink: 

----------

## jburns

Use the --kernel-config=<your .config file> option with the genkernel command, where <your .config file> is the path and file name for the file.

----------

## k0OA1

 *OldTango wrote:*   

> I manually build all my own kernels and have never used genkernel so I am not sure how it works. Based on your output, your setting "make mrproper" which should clean all objects and .configs from your kernel sources.  Are you sure this is what you want?
> 
> From the Gentoo Genkernel Wiki: *Quote:*   --[no-]mrproper
> 
>     Activates (or deactivates) the make mrproper command before kernel compilation. Like the make clean command listed above, make mrproper removes all object files and dependencies from the kernel's source tree. However, any previous configuration files (in /path/to/sources/.config or /path/to/sources/.config.old) will also be purged from the kernel's source tree. If it is undesirable that the kernel's .config file keeps disappearing, be sure to disable this option! 
> ...

 

It looks like the same error occurs with these options disabled:

```

$ sudo genkernel all  --no-mrproper --no-oldconfig --kernel-config=/usr/src/linux/.superkoala-31.6

* Gentoo Linux Genkernel; Version 4.0.0_beta20

* Using genkernel configuration from '/etc/genkernel.conf' ...

* Running with options: all --no-mrproper --no-oldconfig --kernel-config=/usr/src/linux/.superkoala-31.6

* Working with Linux kernel 5.3.11-gentoo-x86_64 for x86_64

* Using kernel config file '/usr/src/linux-5.3.11-gentoo/.superkoala-31.6' ...

* 

* Note: The version above is subject to change (depends on config and status of kernel sources).

* kernel: >> Initializing ...

*         >> Running 'make clean' ...

*         >> --no-mrproper is set; Skipping 'make mrproper' ...

*         >> --no-oldconfig is set; Skipping 'make oldconfig' ...

*         >> Running 'make olddefconfig' due to changed kernel options ...

*         >> Compiling 5.3.11-gentoo-x86_64 bzImage ...

^Z

```

Would you please share your method for manual building of the kernel? Thank you.

 *jburns wrote:*   

> Use the --kernel-config=<your .config file> option with the genkernel command, where <your .config file> is the path and file name for the file.

 

Thanks, tried it but doesn't seem to make any difference.

----------

## Whissi

 *k0OA1 wrote:*   

> I am experiencing an issue where the .config file I'm using is overwritten just before compilation.
> 
> I used eselect kernel to specify the latest gentoo-sources (linux-5.3.11-gentoo)
> 
> Next, I copied my old config to /usr/src/linux/
> ...

 

Thank you for testing genkernel-4!

No, this is not a bug. Please view genkernel.log: You will see a message like

```

* kernel: >> Initializing ...

*         >> --no-clean is set; Skipping 'make clean' ...

*         >> --no-mrproper is set; Skipping 'make mrproper' ...

*         >> Will ignore kernel config from '/proc/config.gz'

*            in favor of already existing but different kernel config

*            found in '/usr/src/linux/.config' ...

*         >> Running 'make oldconfig' ...

COMMAND: nice -n10 make -j 31 -l 31.8  ARCH="x86" oldconfig

scripts/kconfig/conf  --oldconfig Kconfig

#

# No change to .config

#

*         >> Invoking menuconfig ...

COMMAND: nice -n10 make -j 31 -l 31.8 -j1  ARCH="x86" menuconfig

*         >> Ensure that CONFIG_LOCALVERSION is set ...

*                  - Setting option 'CONFIG_LOCALVERSION' to '"-x86_64-test1"' in '/usr/src/linux/.config'...

```

Do you already spot what's going on? We are using your changed .config but because we added --kernel-localversion and --kernel-append-localversion options in genkernel we must apply these settings after the user has made all changes so we can be sure that values set via genkernel will be last set value.

So you are changing values in menuconfig which will get overwritten later by set KERNEL_LOCALVERSION/KERNEL_APPEND_LOCALVERSION from genkernel. Your .config isn't ignored!

----------

## linear

 *Whissi wrote:*   

> Do you already spot what's going on? We are using your changed .config but because we added --kernel-localversion and --kernel-append-localversion options in genkernel we must apply these settings after the user has made all changes so we can be sure that values set via genkernel will be last set value.
> 
> So you are changing values in menuconfig which will get overwritten later by set KERNEL_LOCALVERSION/KERNEL_APPEND_LOCALVERSION from genkernel. Your .config isn't ignored!

 

But, since CONFIG_LOCALVERSION and CONFIG_LOCALVERSION_AUTO are kernel configurations, aren't you ignoring and overwriting them in favor of the newly-added --kernel-localversion and --kernel-append-localversion options?  That certainly is the way it seems.  

It took me finding this thread to realize that was what was going on.  I kept wondering why genkernel wasn't appending my date-version string and kept overwriting it's own config under /etc/kernels/.

Perhaps an eselect news item about the new options and behavior could have been put out?  Just a thought.

----------

## Whissi

We are talking about a thread from 2019... but let me add a few things:

We usually do news items only for breaking stuff and when user interaction will be required, see GLEP 42.

Every user upgrading to v4 will see an elog that genkernel 4 changes a lot of stuff and that it is highly recommended to re-read documentation, pay attention to program output etc., see https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-kernel/genkernel/genkernel-4.1.2-r3.ebuild?id=03c8706669ea347ef26610b0d6c12332ca52eda2#n238

The change is mentioned in man page

When you pay attention to program output as told, you will see what's going on,  *Quote:*   

> 
> 
> *         >> Ensure that CONFIG_LOCALVERSION is set ...
> 
> *                  - Option 'CONFIG_LOCALVERSION="-x86_64"' already set in '/usr/src/linux/.config'; Skipping ...
> ...

 This is also always recorded in genkernel.log.

We also had a news item regarding new default naming...

Don't get me wrong. If you have a suggestion how we can do better next time, I am all open and listening. But I think we really did a lot and it sounds like you just missed all of that.

 *Quote:*   

> I kept wondering why genkernel wasn't appending my date-version string and kept overwriting it's own config under /etc/kernels/.

 This sounds like another misunderstanding: You are talking about --safe-config feature, to quote man page: *Quote:*   

> Saves, or does not save the kernel configuration to /etc/kernels if the kernel is successfully compiled.

 That's it. Genkernel always used and made changes to kernel config working copy. After kernel is successfully compiled, it just copied that used working copy to /etc/kernels. Nothing more, nothing less. This hasn't changed. So I am wondering a little bit why you wonder that stuff in /etc/kernels will get overwritten...

----------

## linear

Well, I just checked through my (screen)logs of the world update where genkernel was upgraded from 4.0.4 to 4.1.2-r3, and did not see an elog for genkernel in them.  As you pointed out in the commit, it only showed when going from versions <4 to versions >=4.

I personally did not do the upgrade of genkernel from 3.5.3.3 to 4.0.4 on this server, and the person who did that upgrade did not do so in a logged screen session so yes, I did completely miss it from there.  (That person is also no longer with our team, so that shouldn't happen again.)

However, the part that was troubling me was the fact that, while I had defined CONFIG_LOCALVERSION and CONFIG_LOCALVERSION_AUTO within the kernel via menuconfig, as shown here (by a separate save of the config within menuconfig):

```
#

# General setup

#

CONFIG_INIT_ENV_ARG_LIMIT=32

# CONFIG_COMPILE_TEST is not set

CONFIG_LOCALVERSION="-x86_64-20210121-01"

CONFIG_LOCALVERSION_AUTO=y

CONFIG_BUILD_SALT=""

CONFIG_HAVE_KERNEL_GZIP=y

CONFIG_HAVE_KERNEL_BZIP2=y

CONFIG_HAVE_KERNEL_LZMA=y
```

it would keep getting reset as follows:

```
#

# General setup

#

CONFIG_INIT_ENV_ARG_LIMIT=32

# CONFIG_COMPILE_TEST is not set

CONFIG_LOCALVERSION="-x86_64"

CONFIG_LOCALVERSION_AUTO=y

CONFIG_BUILD_SALT=""

CONFIG_HAVE_KERNEL_GZIP=y

CONFIG_HAVE_KERNEL_BZIP2=y

CONFIG_HAVE_KERNEL_LZMA=y
```

And, yes, I look at the output in genkernel.log, and I see the following:

```
*         >> Ensure that CONFIG_LOCALVERSION is set ...

*                  - Setting option 'CONFIG_LOCALVERSION' to '"-x86_64"' in '/usr/src/linux/.config'...
```

which is different than what you were showing.

So, now I understand that if I want to get my date-version string appended to the config saved in /etc/kernels/, I need to use --kernel-localversion and --kernel-append-localversion options... Well, maybe just --kernel-append-localversion option as all I want is to add the date of creation/compilation and version of that date.  

We have always let the default #SAVE_CONFIG="yes" in genkernel.conf as I like to have a copy of the config when I know it has compiled.  And, having all the successfully compiled kernel configs through the different kernel versions in one place makes it easier to check on kernel support for different things.  But, when you are re-running genkernel and it keeps resetting the CONFIG_LOCALVERSION to "-x86_64", then when it saves, it will write over the last config of the same kernel version that was saved under /etc/kernels/, as it is the same name for the file (e.g. /etc/kernels/kernel-config-5.4.72-gentoo-x86_64).  It doesn't append ".old" on the existing file there like it does for initramfs, System.map and vmlinuz under /boot/.  But, as you pointed out, that should no longer be an issue with --kernel-append-localversion.

Lastly, if it feels like I am "necro-posting", I apologize.  However, as I said, it was this thread that got me caught up as to what was happening and what I needed to do.  Thanks.

----------

