How to save or export a custom Linux kernel configuration?

I downloaded a Linux Kernel from www.kernel.org, then I used menuconfig to customize it.

After a lot of customizing it works just like I need it to, and I don't want to loose this actual configuration, so I could later (in another machine, by example) download the same kernel version, and use my configuration. How could I do that?


Solution 1:

Just copy .config file from source directory. This file contains your current configuration.

Also when updating sources you can do make oldconfig to preserve old changes and only decide what to do with new stuff, it will only ask about new configuration options (updates current configuration). You still need to move in your old .config file before you can use this.

Solution 2:

One option is:

make savedefconfig

which will create a file named defconfig in your current directory. You can now copy this file to arch/<architecture>/configs/my_defconfig (take care that the file name has to end with _defconfig), e.g.:

cp defconfig arch/x86/configs/my_defconfig

When you've done this you can type the following to generate the .config from your configuration (for the provided architecture):

export ARCH=x86
make my_defconfig

I think this is preferred way to store kernel configurations and once it is set up it is easier to maintain since you can easily switch from one configuration to another.

Solution 3:

You can either save the config file to a custom location directly in menuconfig and load a custom one there as well or you can save the .config file from the kernel source location eg /usr/src/linux/.config

To save directly in menuconfig scroll down to the last two options Load / Save an Alternate Configuration File