Command to Reduce File Size of Installed Kernel Modules

I mentioned the objcopy command earlier, but I had recently put it into effect myself by shaving off quite a bit of bulk from Linux kernel modules targeted towards an embedded system and I wanted to share my steps and commands with you.

  1. Step 1: Compile your kernel and install the modules
  2. make; make modules_install
  3. Step 2: Change to the directory in which you installed your kernel modules
  4. cd /lib/modules/
  5. Step 3: Run the following command which will find all files ending in .ko and pipe it to run the objcopy command (note, the following shows an example of using cross compile tools targeted towards ARM)
  6. find . -type f -name '*.ko' | xargs -n 1 /myfiles/tscrosstool/crosstool-linux-arm-uclibc-3.4.6/arm-uclibc-3.4.6/bin/arm-linux-objcopy --strip-unneeded

That’s it. You’ll notice that your kernel module sizes are now very small compared to what they used to be, and this allows you to squeeze in more features in your embedded system and possibly leave even more free space for your programs or files.

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:

There's 0 Comment So Far

Share your thoughts, leave a comment!