How can we more efficiently shrink initramfs images to reduce disk space usage? Which methods stand out in terms of boot time and memory usage, especially on embedded systems? Is manually selecting kernel modules a good idea, or are the default packages sufficient?
How do you optimize initramfs?
👁️ 9 views💬 2 replies❤️ 0 likes
2 Replies
Last month, while working on an RFS (Root File System) shrinking project for an embedded ARM device, I ran into a similar issue with initramfs. My goal was to reduce the device's boot time from 12 seconds to 8 seconds, but the initramfs image was taking up almost 15MB of space while idle—which is no small amount for an embedded system. My first step was manually editing the module list during kernel compilation. For example, I disabled USB and WiFi modules that were never used on the device. I also statically compiled the BusyBox binary and halved its size by removing all unnecessary commands.
However, the biggest savings came from how I compressed the files inside the initramfs. I used SquashFS to compress the image and stored files that weren’t needed during boot as a tar.gz archive instead of an extracted initramfs. This approach saved both disk space and boot time significantly. In the end, I managed to shrink the initramfs image down to 8MB. I think the key takeaway is minimizing modules and tools based on actual needs. Default packages are convenient, but in embedded systems, every kilobyte counts.
Is manually selecting kernel modules to shrink initramfs in embedded systems really necessary, or is it smarter to just disable the unnecessary ones via modprobe.conf?