39

When building a new kernel based on a previous config, is there a way to automate the make oldconfig process so that it sets new options to their default values?

Edit: What I mean is that when using a .config (from /boot/config-* or /proc/config.gz) on a newer kernel, the make oldconfig process will ask wether or not you want to enable options that were not available in your older kernel. You can answer Y/n/m or press enter to accept default. I would like to accept defaults automatically with no user interaction.

1
  • @jscott This would only "press enter" for the first question, not all of them. You can use the 'yes' command to have a string printed indifinitly. Feb 24 '10 at 18:34
42

Use the command :

yes "" | make oldconfig

The 'yes' command repeatedly output a line with all specified string, or 'y' by default.

So, you can use it to simply "press enter", which will result in using the defaults value for the 'make oldconfig' command.

4
  • Ahh, I didn't know the 'yes' command could output any string. Thank you! Feb 24 '10 at 18:35
  • 3
    This is phenomenal.
    – Ivan X
    Dec 19 '15 at 13:57
  • 1
    Answer is a much better idea serverfault.com/a/538150/18822 Aug 11 '17 at 13:39
  • v3.4: "Console input/output is redirected. Run 'make oldconfig' to update configuration."
    – fuzzyTew
    Nov 10 '20 at 21:14
65
make olddefconfig

is what you want. From the help (make help in the kernel source dir)

olddefconfig - Same as silentoldconfig but sets new symbols to their default value

3
  • I've been looking for something like this for a while... thanks alot! Dec 11 '14 at 18:28
  • 1
    Which version of Linux did this arrive? Just curious. I'm currently handling an old version (3.0) and it doesn't have it yet.
    – clacke
    Dec 21 '16 at 17:43
  • 1
    This should be the correct answer.
    – suprjami
    Apr 17 '17 at 23:48
0

Yes. It's stored in ".config" in the top level of the source directory.

Additionally, if using distribution kernel, some distributions such as RedHat store it in /boot/config-$(uname -r). (kernel version) [1]

Finally, if compiled in the kernel you're running, it's available in /proc/config.gz. I forget what version introduced this option.

[1] These options:

CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y 

Edit

Check out /usr/src/linux/kernel/Documentation/kbuild/kconfig.txt (or appropriate path). You can use some of their recommendations to script a solution. I would use a combination of scripting and textutils to accomplish what you describe.

Edit 2

As an additional note, this is a bad idea. What if optional hardware support unique to your environment changes but isn't default? What if a negatively impacting changes occurs? This really is something that should be interactive. You can make the config and automate the rest.

"make silentoldconfig" is a little less verbose, which might be helpful. It is still interactive.

1
  • That's not what I meant. I have added more details to my question to explain what I want to achieve. Feb 24 '10 at 16:23
0

make silentoldconfig

1
  • 3
    make silentoldconfig is still interactive, it is just less verbose Feb 24 '10 at 18:32
0

Though an old question, I never found a good answer to OP's question.

I found another way around the interactive questions; rather than patching .config, I patch the defconfig file, i.e.

make ARCH=arm mrproper
patch -N -p1 < ../../patches/autofs.patch || true
make ARCH=arm xilinx_zynq_defconfig
make ARCH=arm UIMAGE_LOADADDR=0x8000 uImage
make ARCH=arm modules
make ARCH=arm INSTALL_MOD_PATH=target modules_install

The patch in my case:

--- a/arch/arm/configs/xilinx_zynq_defconfig    2019-12-12 08:31:42.985777534 +0100
+++ b/arch/arm/configs/xilinx_zynq_defconfig    2019-12-12 08:31:46.695777606 +0100
@@ -221,6 +221,7 @@
 CONFIG_XILINX_PR_DECOUPLER=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
+CONFIG_AUTOFS4_FS=y
 # CONFIG_DNOTIFY is not set
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y

This way no questions are asked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.