I regularly create packages for Slackware Linux and part of the process is stripping binaries so that they take up less space. I find that if I strip --strip-all (or strip with no options) kernel modules, they often fail to insert:

FATAL: Error inserting cloop (/lib/modules/ Invalid module format

What level of stripping is recommended for kernel modules? If I use --strip-debug, will I remove debugging symbols that will negatively affect system performance and/or error logging?


Stripping all symbols removes the names of the symbols that the module calls. It's not going to work.

Stripping debugging symbols with strip --strip-debug *.ko (= strip -g *.ko) is safe. The kernel makefile does it for you if you run make INSTALL_MOD_STRIP=1 modules_install.

You can prevent debugging symbols being inserted in the first place by configuring your kernel with CONFIG_DEBUG_INFO not defined.

See also How do I strip local symbols from linux kernel module without breaking it?

| improve this answer | |

I believe the safest approach is strip --strip-unneeded.

| improve this answer | |
  • 1
    I see that --strip-unneeded also strips .modinfo section, including the 'module depends' and the 'vermagic' things. Unsure what would be the consequences. – PypeBros Nov 29 '17 at 13:22

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.