In this lesson, you will learn how to shrink your Embedded Linux root filesystem to fit within constrained storage limits without sacrificing runtime functionality.
Stripping Symbols and Documentation
When you compile applications for a development environment, the binaries often contain "debug symbols"—metadata that links machine code back to source code lines. In a production embedded system, this information is useless bloat. You can reclaim significant space by using the strip utility on your binaries:
# Remove all symbols from the binary
arm-linux-gnueabihf-strip my_application
Similarly, documentation files (like man pages, info files, and header files) are unnecessary for an embedded device. Deleting these directories from your target root filesystem (/usr/share/man, /usr/share/doc) is an immediate "quick win" for storage optimization.
Selecting Filesystem Compression
The choice of the underlying filesystem format dictates how storage is utilized. For read-only embedded partitions, you should avoid heavy filesystems like ext4 in favor of compressed, flash-aware alternatives like SquashFS.
SquashFS uses high-ratio compression (such as xz or zstd) to store files. Because it is a compressed, read-only filesystem, the kernel decompresses data on-the-fly when read into memory. This effectively multiplies your available storage capacity.
Strategic Library Pruning
Shared libraries often consume the largest portion of your filesystem. Beyond stripping symbols, you must ensure you are not bundling unused libraries. If your application only uses a small fraction of a large library (like glibc), consider switching to a space-optimized alternative like musl or uClibc. You can also use tools like ldd to audit which shared objects are actually being loaded at runtime by your binaries:
# Check dependencies of your application
arm-linux-gnueabihf-ldd my_application
If you find a dependency that isn't required for core functionality, remove the library and reconfigure your application to omit the associated features. By systematically removing metadata, purging non-essential documentation, and employing compressed filesystems like SquashFS, you can reduce your rootfs footprint by 50% or more.
Key Takeaway: Minimizing your filesystem is a three-pronged strategy: strip unused binary metadata, prune non-runtime documentation, and utilize compressed read-only filesystems to maximize your physical storage density.