Ubuntu 18.04 stuck at upgrading linux-header

TLDR: Disable Secure Boot.

I started having this same issue about a month ago. For me it turns out the solution was disabling Secure Boot. I've had Secure Boot disabled since I installed Ubuntu 18.04 and it's upgraded without any problems. However, about a month ago, I updated my BIOS which re-enabled Secure Boot (I didn't know this at the time). It was frustrating having the upgrades freeze and I finally figured it out because my VirtualBox installation was also not working. The fix for VirtualBox was disabling Secure Boot which also fixed my linux-headers-<version>-generic upgrades.

As noted in the question, it would freeze here:

...
Setting up linux-headers-4.15.0-38-generic (4.15.0-38.41) ...

After disabling Secure Boot, I get:

...
Setting up linux-headers-4.15.0-38-generic (4.15.0-38.41) ...
/etc/kernel/header_postinst.d/dkms:
Secure Boot not enabled on this system.
...
done

My solution;

  • ps aux | grep apt
  • Kill the apt process
  • sudo dpkg --configure -a
  • apt update
  • apt upgrade