0

I just viewed the .config of ubuntu in /usr/src/linux-headers-5.3.0-46-generic/.config. There is CONFIG_KVM=m. But when I use lsmod, kvm moudle is in the output. CONFIG_XX=m means that the moudule is not compiled into the kernel. You can use "modprobe xxx.ko" to load the module. lsmod shows which loadable kernel modules are currently loaded.

But my CONFIG_KVM=m and I do not use modprobe. Why is KVM in the output of lsmod? Thanks

1 Answer 1

0

As describe here kvm is automaticaly loaded on boot on cpus which support hardware virtualization.

If you don't need virtualization you can disable VT-d/AMD-V in your BIOS to prevent module kvm to load on boot

Update:

Build as module allows you to have a faster boot by loading only specific features onboot. It does not guarantee to you that a module will not be loaded. If a ressource need this module it could be loaded directly by the binary like iptables does.

Example:
nf_conntrack is an iptables modules which allows you to track connections through the firewall CONFIG_NF_CONNTRACK=m. This module will not be loaded unless you add a rule using -m conntrack.

Other example:

My computer have an ethernet card using driver e1000.

grep CONFIG_E1000 /boot/config-4.15.0-91-generic

CONFIG_E1000=m
CONFIG_E1000E=m
CONFIG_E1000E_HWTS=y

It shows me the e1000 driver is built as module.

Using modinfo e1000 | alias will gives all aliases that will load the kernel module automatically

alias:          pci:v00008086d00002E6Esv*sd*bc*sc*i*
alias:          pci:v00008086d000010B5sv*sd*bc*sc*i*
alias:          pci:v00008086d00001099sv*sd*bc*sc*i*
alias:          pci:v00008086d0000108Asv*sd*bc*sc*i*
...

Since my ethernet card is an intel (VendorID 8086) it matches to the alias, so the module is loaded as shown in dmesg

[    1.520584] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k

All the modules you see in lsmod after a fresh boot were used during the boot process.

10
  • So except KVM, other modules should not in the output of lsmod, if their CONFIG=m, not y ?
    – David Lee
    Apr 22, 2020 at 1:32
  • Build as module allows you to have a faster boot by loading only specific features onboot. It does not guarantee to you that a module will not be loaded. If a ressource need this module it could be loaded directly by the binary like iptables does.
    – Fractalyse
    Apr 22, 2020 at 2:12
  • can you give more details about iptables?
    – David Lee
    Apr 22, 2020 at 2:28
  • I've edited my previous answer
    – Fractalyse
    Apr 22, 2020 at 10:51
  • I want to confirm: if a module's CONFIG_XXX=m, it does not mean that the module will not be loaded automatically on boot. Also, if you do not use modprobe, some CONFIG_XXX=m module can still be in the output of lsmod. Thanks
    – David Lee
    Apr 22, 2020 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.