47

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, 2010 at 18:34

5 Answers 5

48

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.

5
  • Ahh, I didn't know the 'yes' command could output any string. Thank you! Feb 24, 2010 at 18:35
  • 4
    This is phenomenal.
    – Ivan X
    Dec 19, 2015 at 13:57
  • 2
    Answer is a much better idea serverfault.com/a/538150/18822 Aug 11, 2017 at 13:39
  • v3.4: "Console input/output is redirected. Run 'make oldconfig' to update configuration."
    – fuzzyTew
    Nov 10, 2020 at 21:14
  • @EvanCarroll While I agree that make olddefconfig is a better idea for situations where such a target is available, the solution in this answer is more broadly applicable... :) Right now, I had that problem with Busybox and this solution worked nicely!
    – mh166
    17 hours ago
76
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, 2014 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, 2016 at 17:43
  • 1
    This should be the correct answer.
    – suprjami
    Apr 17, 2017 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, 2010 at 16:23
0

make silentoldconfig

1
  • 3
    make silentoldconfig is still interactive, it is just less verbose Feb 24, 2010 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .