Fixing corrupted initramfs images

A few days ago my Ubuntu installation got corrupted during what should have been an easy no worries apt-upgrade. What happened though is that during the apt-upgrade, precisely during kernel updates, my system crashed. Afterwards, I was not able to boot anymore due to lib modules missing.

So the usual was to be done, get a usb rescue stick, chroot and try to complete the upgrade. Unfortunately, the system still did not boot. During boot, my filesystem could not be decrypted. Sigh.

After stumbling around for a bit, I finally came across a helpful stackoverflow post explaining the following:

The cryptsetup modules are only added to the initramfs image “when there is a device that needs to be unlocked at initramfs stage (such as root or resume devices)” (See: conf-hook). But this currently only works (reliably) if the root device is not in an (encrypted) LVM.

To force the cryptsetup modules to the initramfs image you have to set CRYPTSETUP=y in /etc/cryptsetup-initramfs/conf-hook.

This exactly described my situation, I did have an encrypted FS within an logical volume. So set the flag to yes, and was able to boot again 🙂 Note that this setting is soon to be deprecated and might not work anymore.