Linux – Delete kernel module completely

kernelkernel-modulelinux

I would like to ask you how can I delete some kernel module completely? I mean really delete, not unload or prevent to load. I tried to use rmmod, but it just unloaded module, same as modprobe -r. So I got list of all modules using modprobe -n -v and deleted them manually.

rmmod cramfs:
ERROR: Module cramfs does not exist in /proc/modules

so when I try to load module, I got:

modprobe -v -n cramfs:
FATAL: Could not open '/lib/modules/2.6.32-573.12.1.el6.x86_64/kerne/fs/cramfs/cramfs.ko': No such file or directory

but that means, system still got some information about removed module because it knows the path to the cramfs.ko file. Example of not loaded, but loadable module:

modprobe -v -n jffs2
insmod /lib/modules/2.6.32-573.12.1.el6.x86_64/kernel/lib/zlib_deflat/zlib_deflate.ko 
insmod /lib/modules/2.6.32-573.12.1.el6.x86_64/kernel/fs/jffs2/jffs2.ko

rmmod jffs2
ERROR: Module jffs2 does not exist in /proc/modules

Is there any way how to delete modules correctly?

Best Answer

Modules are loaded into RAM (and linked to the running kernel) at runtime when required somehow. Until that happens, they (only) use disk space (or it's equivalent).

You can save a bit of disk space by building your own kernel that has the module configured out. The kernel will be a very tiny bit faster using the relevant functionality if you build a kernel that includes (not as modules, builtin) whatever you need. But that is a huge hit in flexibility and hassle.

Related Question