Booting recent Ubuntu machines with custom built Linux Kernels

One frustration I had after beginning to use Ubuntu 20.04 (LTS) was that from some point, I just could not install a Linux kernel I built and boot the system up. My usual workflow was:

make install -jXX
sudo make modules_install
sudo make install

However my boot would stall while loading the ramdisk – much like this ask-ubuntu question. Fortunately, now, it seems to be that the initramfs size is too large (why does this matter?) causing the stall. The answer to the question above recommends stripping the modules:

sudo make modules_install INSTALL_MOD_STRIP=1

This shall ‘strip’ the modules after they are installed. (And I assume, this would reduce the module size in the initramfs).

Another method that Alireza found was to change the initramfs behavior. Changing the MODULES=dep in the /etc/initramfs-tools/initramfs.conf should reduce the initramfs size down. After changing this, my guess is either

$ sudo make install
$ #or
$ update-initramfs -c -k KERNEL_VERSION

And try booting again 🙂