Yes; /proc/config.gz
, if it exists, always refers to the running kernel's configuration (but see the last few paragraph below) since procfs
, like sysfs
and devtmpfs
, which are used to implement the trees mounted at /proc
, /sys
, and /dev
respectively are not on-disk storage or files at all in a conventional sense (depending what your "conventional" is). They're kernel interfaces, which is why most of them have a size of zero -- config.gz
is an exception in this sense and will stat an actual and appropriate size, but it still only exists in RAM as part of the kernel.
This is an optional feature, and it may be compiled as a module, which it is in the Raspbian kernels. This means to find it you first have to:
sudo modprobe configs
And presto, /proc/config.gz
will appear. For those unfamiliar with .gz
this is a compression format; you need to copy that out and uncompress it, and note since you can't write new files to /proc
it must be to somewhere else. In one step:
gunzip -c /proc/config.gz > ~/kernel.config
You don't need to use sudo
since the file is world readable.
Beware that the configuration is from when the kernel was compiled, and includes options that were compiled as modules. Since you can remove modules from the system and install new ones without recompiling the kernel, it can be inaccurate in that sense. This is relevant if you build your own kernel, then add modules later, then use that file to configure another (upgraded) kernel down the line -- any of the modules you added in the meantime won't be included.
I'd also guess when modular you could swap in a different configs.ko
which could report a completely different configuration. I haven't tried this but I should since it would resolve the "whoops what did I do with the real current configuration" issue just mentioned...