Compiling the kernel with default configurations
Solution 1
It is not recommended just a bare make menuconfig
. The required config depends on three things:
- the hardware being used
- the features used by the OS/distribution
- the features used by you (file-systems, raid, ..etc)
So the recommended "default" config in my view is:
cd your_kernel_src
cp /boot/your-distribution-config .config
make localmodconfig
make menuconfig
See also Kernel configuration for distributions. The first paragraph:
Configuring a kernel was once a fairly straightforward process, only requiring knowledge of what hardware needs to be supported. Over time, things have gotten more complex in general, but distributions have added their own sets of dependencies on specific kernel features—dependencies that can be difficult for regular users to figure out. That led Linus Torvalds to put out an RFC proposal to add distribution-specific kernel configuration options.
Solution 2
Real hardware / distros will likely not work properly with defconfig
As mentioned on this answer, anything that is not given by the distribution or hardware vendor will very likely fail in subtle or less subtle ways, e.g.:
- you might not build driver support for some essential piece of hardware
- packages of the distribution might rely on a feature of the kernel that you did not build and fail
Furthermore, besides specific configs, it is normal for vendors to apply large patchsets on top of the vanilla kernel, even Ubuntu does this for example.
For Ubuntu / Debian in particular, I have described how to compile the supported kernel from source at: https://askubuntu.com/questions/281763/is-there-any-prebuilt-qemu-ubuntu-image32bit-online/1081171#1081171 Modifying that stable kernel base is the sanest thing you can do in that case.
QEMU works with defconfig
One thing that defconfig
does nicely though, it to boot on QEMU, tested on kernel v4.20, QEMU 2.12.
Here is a fully automated example with Buildroot.
As noted on that link, you need the following options to boot from disk:
CONFIG_VIRTIO_PCI=y
CONFIG_VIRTIO_BLK=y
although they are not needed for initrd.
For cross compilation to a different arch, e.g. aarch64, you need:
make ARCH=arm64 defconfig
But as explained here, although arm64 does boot on QEMU, it generates a super bloated kernel, and you likely want to roll out something more minimal e.g. as described here.
What make defconfig
does exactly?
We can easily see which config file was used with a verbose build:
make V=1 defconfig
which outputs on v4.19:
make -f ./scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
make -f ./scripts/Makefile.build obj=scripts/kconfig defconfig
scripts/kconfig/conf --defconfig=arch/x86/configs/x86_64_defconfig Kconfig
from which we conclude that the used file must be arch/x86/configs/x86_64_defconfig.
See also: https://stackoverflow.com/questions/41885015/what-exactly-does-linux-kernels-make-defconfig-do
make help
also shows other interesting default related targets like alldefconfig
and savedefconfig
which may be useful.
Solution 3
defconfig is not a filename argument to be used for the .config creation.
instead, defconfig is a makefile target and once called, make will be looking for the configuration to apply depending on ARCH variable provided ahead of make call.
example:
ARCH=arm make defconfig
will be looking in the arch/arm subfolder for the XXX_defconfig file, where XXX exact name is assigned inside the arch/$ARCH/Makefile for each of the architecture.
example:
arch/arm/Makefile:30:KBUILD_DEFCONFIG := multi_v7_defconfig
instead of local folder file defconfig will be applying arch/arm/multi_v7_defconfig one as the default .config
Related videos on Youtube
Aquarius_Girl
Arts and Crafts.stackexchange.com is in public beta now. Join us!
Updated on September 18, 2022Comments
-
Aquarius_Girl over 1 year
Assumptions:
The platform:
anisha@linux-dopx:~/> uname -a
Linux linux-dopx 2.6.34-12-desktop #1 SMP PREEMPT 2010-06-29 02:39:08 +0200 x86_64 x86_64 x86_64 GNU/Linux
The kernel downloaded is the latest stable one from kernel.org.
- We let the defaults remain (make no changes) in the options of
make menuconfig
. - Simply type
make
,make install
,grub-update
, and reboot.
Now, following these assumptions, are we still required to make some additional changes to files or compile some extra drivers to ensure a error free reboot?
If yes, then on what things do those changes depend on?
EDIT 1:
anisha@linux-dopx:/> sudo /sbin/lspci -n 00:00.0 0600: 8086:29c0 (rev 10) 00:02.0 0300: 8086:29c2 (rev 10) 00:1b.0 0403: 8086:27d8 (rev 01) 00:1c.0 0604: 8086:27d0 (rev 01) 00:1c.1 0604: 8086:27d2 (rev 01) 00:1d.0 0c03: 8086:27c8 (rev 01) 00:1d.1 0c03: 8086:27c9 (rev 01) 00:1d.2 0c03: 8086:27ca (rev 01) 00:1d.3 0c03: 8086:27cb (rev 01) 00:1d.7 0c03: 8086:27cc (rev 01) 00:1e.0 0604: 8086:244e (rev e1) 00:1f.0 0601: 8086:27b8 (rev 01) 00:1f.1 0101: 8086:27df (rev 01) 00:1f.2 0101: 8086:27c0 (rev 01) 00:1f.3 0c05: 8086:27da (rev 01) 01:00.0 0200: 10ec:8136 (rev 01)
-
bahamat almost 12 yearsTo put this more succinctly: There's no working "default" or "just what Linus intended" kernel config. If you just download and compile without configuring anything it is expected that you end up with a broken and/or barely functional kernel.