100

Yesterday I started the upgrade from [one version of Ubuntu to the next], but I interrupted it because it was taking too long. Now if I restart it, it doesn't proceed.

Is there any possibility to clean the mess it left when I interrupted it and make a clean restart of this update?

Lambart
  • 2,870
Dave
  • 1,053

6 Answers6

125

It appears that sudo screen -D -r will reconnect to a disconnected install in a 12.04 to 16.04 upgrade. This means no killing of packages or anything like that. This assumes that you didn't actively stop the upgrade, just lost access to the session.

flickerfly
  • 7,509
103

If you're lucky, you might just have a crashed/detached screen (terminal manager) instance. This command should reattach (reconnect) to it:

$ sudo screen -D -r

If that doesn't get you started again (i.e., it says "There is no screen to be detached."), here are some more steps to try:

First, check for/fix broken dependencies (e.g., updates that didn't fully download):

$ sudo apt-get install -f

If it indicates that there are no broken packages, and nothing to download, then try this command. It tells the package manager to fix/reconfigure the existing, unpacked-but-not-yet-configured packages:

$ sudo dpkg --configure -a

You can then try the release upgrade again, but it may already be finished at this point. This last command is actually how I've restarted most broken upgrades which aren't fixed by reattaching to the screen session (see the first suggestion).

If it fails here, I'm not sure. You may want to delete all the already- downloaded packages (they should be stored in /var/cache/apt/archives), do

$ sudo apt-get clean

That will clean up the packages but if you're still stuck in some weird state, I'm not sure what else to suggest.

$ sudo apt-get autoremove -y

That will remove any now obsolete packages.

Of course, before you do anything you should back up any important contents of your /home/dave directory (or whatever your $HOME directory is).

Lambart
  • 2,870
12

My 16.04 to 18.04 upgrade had interrupted as I had stopped the process by mistake. I guess the process was towards the end (installing wifi packages). Nothing of above worked and kept giving "dpkg fronend is locked by another process". A system reboot followed by

$ sudo dpkg --configure -a

resumed the process and completed upgrade to 18.04 successfully.

SDQT
  • 121
10

For me things were a bit different: the process stopped on the download step (because of a power failure).

So no screeen to resume and no packages broken because none were installed, but do-release-upgrade was asking me to upgrade 850 packages first...

The fix was to restore the file /etc/apt/sources.list with

mv /etc/apt/sources.list.distUpgrade /etc/apt/sources.list

and same for all *.distUpgrade in /etc/apt/sources.list.d with

for x in /etc/apt/sources.list.d/*.distUpgrade; do
    mv -- "$x" "${x%.distUpgrade}"
done

Then a simple apt update putted the system in a clean state and I was able to do the release upgrade normally.

Rayzeq
  • 33
Cédric
  • 201
3

Thanks for your hints. I first intended a reboot through the UI. The request was accepted, the screen went blank, but nothing else happened after that. You could see small disk activity for about 30min.

I then used SSH from a Win laptop to login in the Ubuntu system, entered sudo pkill dpkg followed by sudo dpkg --configure -a.

After these, the Ubuntu 20.04 upgrade resumed at the point I had accidentally interrupted it before. 20min later it completed and requested a system reboot.

After the reboot it worked like a charm. Openhab, minidlna, smb and all other services restarted as expected.

Zanna
  • 72,312
Jose
  • 31
1

Seems sudo screen -D -r works well on

16-17 17-18 16-18

Will save the hassle of trying to fix the packages or roll back

emakundi
  • 11
  • 2