93

Yesterday I started the upgrade from 12.10 to 13.04, 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?

3
  • There must be a way to a) delete all temporary data he stored for the last trial or b) tell him to start again. The simple way "just go ahead where you were interrupted" does not seem to work!
    – Dave
    Sep 17, 2013 at 14:33
  • 1
    I'm not sure, but maybe 'sudo apt-get upgrade' and afterwards 'sudo apt-get update' could have fixed it!
    – Dave
    Sep 17, 2013 at 19:08
  • I added instructions to my answer for how to delete all the download packages. As for the upgrade/update, usually you want to do it the other way around: "sudo apt-get update && sudo-apt-get upgrade" (you can do it on one line--the '&&' means the second command will only run if the first succeeds).
    – Lambart
    Sep 17, 2013 at 19:36

6 Answers 6

115

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.

14
  • 6
    Even the "do-release-upgrade" from 14.04LTS to 16.04LTS use screen Mar 5, 2017 at 22:35
  • 3
    Works on 17.10 -> 18.04 LTS! May 15, 2018 at 23:20
  • 1
    I was doing do-release-upgrade over x2go which was probably a bad idea, since remote screen packages get hosed in the process. This saved me.
    – endolith
    Aug 19, 2018 at 3:05
  • 5
    Thank you! This is extremely useful if your SSH connection gets disconnected. Nov 30, 2019 at 16:24
  • 9
    This worked on an interrupted ssh connection during 18.04 -> 20.04 upgrade.
    – John Dunne
    Sep 29, 2020 at 14:55
98

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).

11
  • 2
    confirm that sudo apt-get install -f restarted dpkg for me. my upgrade was interrupted when network connection dropped. prob should use screen when upgrading remotely, which I thought ubuntu did at one point... Mar 9, 2014 at 2:26
  • 7
    do-release-upgrade does start a screen session (with screen escape character ^space), but if the parent do-release-upgrade process dies, that might still kill the whole thing. Be careful about hitting ^c if you start a subshell to poke at a modified conffile, I ran into a problem with that: bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/… Jul 18, 2014 at 3:18
  • 2
    Doing a sudo apt-get dist-upgrade at the top of resuming is also advisable. Just make sure /etc/apt/sources.list has the new distribution in it. Sep 10, 2016 at 5:34
  • 1
    @PeterCordes I just hit that issue today in 2021... 🤦‍♂️ Mar 9, 2021 at 6:21
  • 1
    Thanks! It was the sudo that helped get me back on track, without it screen -D -r did not find anything to reconnect to. Feb 9 at 15:03
11

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.

2
  • This was the simplest recovery for me. Fortunately, the partially upgraded system was rebootable (I had interrupted the config file replacement for Samba). Thanks for documenting this recovery!
    – BobHy
    Oct 23, 2019 at 0:40
  • 4
    I was afraid to follow this exactly, as rebooting when packages are in an unknown state may lead to the system not booting properly. What I did instead was to pkill dpkg, then sudo dpkg --configure -a and reboot after that. Worked like a charm :)
    – iFreilicht
    Jun 11, 2020 at 14:48
8

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.

1
  • This fixed it for me, after I mistakenly shut down a VM while it was upgrading to Ubuntu 23.04 and after it had updated to the new package list.
    – Jwosty
    Jun 9, 2023 at 16:21
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.

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .