apt-get hangs on Setting up grub-pc

Yesterday I did my usual

apt-get update
apt-get upgrade

Everything went fine until it hit

Setting up grub-pc (2.02-2ubuntu8.12) ...

where it became unresponsive. I ended up killing the process and trying to fix it with

dpkg --configure -a

but the same thing happens. If I recall correctly from previous upgrades, grub-pc brings up a text based GUI on the terminal that lets you select some parameter before continuing the process. I suspect the reason it hangs is because it's waiting for me to select something, but I have no way of doing it because the menu never shows up. Does anyone have any idea what may be causing this? I'm afraid of rebooting my computer now. My computer is running Ubuntu 18.04.2 LTS.


Unfortunately I did not find out what was causing the issue, but I did manage to effectively fix the problem. If you're at the stage where apt is stuck, I've found the only way to kill the process is to kill the terminal session. This will leave stale lock files that I removed by hand. I'm almost certain there is a smarter way to go about this, but nothing else I tried worked. You can try your luck with dpkg --configure -a but in my case I had to terminate that process as well because it hangs the same way apt does. Just in case I ran ps -aux | grep dpkg and killed every associated process.

In my desperation I risked rebooting the computer, which ended up also hanging on the very last step, which I saw by hitting esc on the reboot splash screen. I ended up holding down the power button for a hard reset. Booting up the computer worked fine though, and rerunning dpkg --configure -a worked after the reboot, allowing me to finish the configuration for grub-pc.

I have since run apt-get upgrade and apt-get dist-upgrade. Rebooting the machine after this went smoothly, and everything appears to be fine now.


Probably you got a popup to confirm with OK .. Navigate using TAB key until "OK" is highlighted and continue.

If it truly hangs, then

sudo dpkg --configure -a --ignore-depends=grub 

Seems helps bypassing the block.