How to permanently disable kvm modules in Linux?

If you don't plan to use kvm at all, why not simply remove the qemu-system-[ARCH] rpm that supplies it. Also, fedora contains a file /etc/sysconfig/modules/kvm.modules which tells the system to load the kvm modules if virtualization extensions are detected in the processor. Modifying /etc/sysconfig/modules/kvm.modules or removing it altogether should also solve the problem, but removing the package seems like it would be the best solution.


Update: For Fedora, save the blacklist lines under Option 1 below into a file under /etc/modprobe.d/, for example, /etc/modprobe.d/blacklist. The name of the file isn't important; all files in the directory get processed during boot.

Option 3 might be more preferable if you're sure you'll never need to load these modules dynamically.

Option 1: Blacklist

Many distros use a module blacklist to disallow module loading. Normally this can be done by adding these lines to your distro's modules.conf or similar. You might try reading man modules.conf or googling for directions for your specific distribution.

blacklist kvm_intel
blacklist kvm

Option 2: Unload

An alternative is to add these lines to your rc.local script (or some other system boot-time script, preferably not one associated with a package):

modprobe -r kvm_intel
modprobe -r kvm

Option 3: Disable (new)

Both of the above will prevent the modules from getting loaded on bootup, but won't stop them from loading into the kernel later. To completely disable the module, use these lines -- again, they can go in a modules.conf file, or in /etc/modprobe.d/disabled or similar:

install kvm_intel /bin/true
install kvm /bin/true

What this does is tell the system to run /bin/true whenever these modules are requested. The program doesn't do anything except return true, so any load "succeeds" but the modules are never actually loaded. To re-enable drivers disabled with this technique, comment out these lines and reboot.