update-initramfs is stuck

Today I've also encountered this error and removing then reinstalling initramfs-tools have fixed the hangs I've been experiencing.

sudo apt remove initramfs-tools
sudo apt install initramfs-tools

In my case, it was probably some configuration or a temporary file was broken / locked for initramfs-tools.

This was on Ubuntu 18.04 so it can still happen.


Okay, I have found a workaround to fix this error.

  1. After I executed the steps in my question, I tried to remove the kernel with:

    sudo update-initramfs -k 3.5.0-23-generic -d
    
  2. After a reboot GRUB showed up and selected my version of Ubuntu but when it tried to load the kernel, it said

    Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block (0,0)

  3. Then I just chrooted with a LiveCD into Ubuntu and executed:

    sudo dpkg --configure -a
    sudo apt-get install linux-image-3.5.0-25-generic
    

    And after a reboot everything was OK.


Step 2 of slashcrack’s sounds largely unnecessary. Instead it should suffice to run

sudo update-initramfs -d -k <VERSION>
sudo apt-get install -f

where you replace <VERSION> with the affected kernel version string (here: 3.5.0-23-generic).