Occasionally, I have to re-install a kernel and its modules. Worse, I have to do it on Ubuntu (for reasons outside my control). I learned to do that on my own mostly through a mixture of old Gentoo tutorials and kernel documentation.

And yet, twice already I have done the whole procedure, which, once your configuration is done, and after you've enabled kernel debugging[1], is something akin to:

make -j4 bzImage modules # i have four cores
sudo make INSTALL_MOD_PATH=/usr modules_install
sudo make INSTALL_HDR_PATH=/usr headers_install
sudo cp arch/x86/boot/bzImage /boot/vmlinuz-myversion
sudo update-initramfs -k myversion -c -v

and then: kaboom. My initrd-myversion is something like 1.2 gigabytes on disk (if like me you are compiling the x86_64-defconfig profile with minimal changes).

Yikes.

I know from experience that your bootloader is likely not going to love having such a huge file to load. Kernel install blunder once: shame on me. Kernel install blunder twice: let's write about it.

The first time it happened to me, I spent about twenty minutes figuring out that symbols were enabled, and clogged up the initramfs size.

I ended up also finding out that Linux's industrial Rube Goldberg machine of a Makefile architecture can read from another environment variable called INSTALL_MOD_STRIP. When the value in that variable is 1, modules are stripped at install, removing the symbols.

I ended up building a new initramfs, at 99 megabytes of size. Interestingly enough, I have never had such an issue on ArchLinux using mkinitcpio. My theory is that it either never pulls all of the modules into initramfs (very likely true from my knowledge so far), or strips them, or both.

TL;DR: Use INSTALL_MOD_STRIP=1 on make modules_install to reduce initramfs size:

make -j4 bzImage modules # i have four cores
sudo make INSTALL_MOD_PATH=/usr modules_install
sudo make INSTALL_HDR_PATH=/usr INSTALL_MOD_STRIP=1 headers_install
sudo cp arch/x86/boot/bzImage /boot/vmlinuz-myversion
sudo update-initramfs -k myversion -c -v

  1. i do kernel development, so i need symbols in core, but not in most modules.