Ideal way to create a new defconfig file

I am looking at creating a new defconfig file.
This used to work with 3.x kernel releases , so looking at getting feedback on whats the ideal/ correct way of doing this.

First generate the .config
make CROSS_COMPILE=$CROSS ARCH=$ARC -j8 defconfig distro.config
Then customize that using make menuconfig
Then save the config
make CROSS_COMPILE=$CROSS ARCH=$ARC savedefconfig

Now copy defconfig kernel/configs/distro2.config

This no longer seems to take effect though. Because the next time I run the below command the modules I had unchecked seem to still be available !
make CROSS_COMPILE=$CROSS ARCH=$ARC -j8 defconfig distro2.config

PS : I dont want to disturb the original ./arch/arm64/configs/defconfig file .

defconfig command is defined as:

make ARCH=<arch> <platform>_defconfig fragment.config fragment2.config ...

When running defconfig, the kernel build system follows several steps:

  • Retrieve platform defconfig from arch/*/configs/, in your case, you do not specify a specific platform defconfig, so the default arch/arm64/configs/defconfig is used.
  • Merge the fragment(s) from kernel/configs if specified, in your case kernel/configs/distro.config
  • Generate a new kernel configuration (.config) with the default answer being used for all options, from Kconfig or overridden by the defconfig+fragments.

Fragments have been created to modify the kernel configuration beyond what the hardware platform requires in order to support a particular additional hardware or software feature.

So I suggest I would suggest to create your own fragment and run something like

make ARCH=arm64 defconfig distro.config myconfig.config

To create your fragment you can just use diffconfig to get the difference between original defconfig (save .config) and the one saved after using menuconfig.

Which symbol are you trying to unselect?

Brilliant thanks for sharing this ! I was a tad bit confused but this clarifies exactly what needs to be done next !

So I used diffconfig under ./scripts/diffconfig .config custom.config > fragment2.config.
However i get unexpected data: -ARCH_TEGRA_132_SOC y (and several other messages such as that , which I had deselected ) when i try to compile the kernel .

sorted this out had to use ./scripts/diffconfig -m .config custom.config > fragment2.config.