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?

Zanna
  • 70,465
Dave
  • 983
  • 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 '13 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 '13 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 '13 at 19:36

6 Answers6

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.

flickerfly
  • 7,279
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).

Lambart
  • 2,760
  • 1
  • 22
  • 27
  • I did everything you wrote here. Thanks for the detailed advice! But I'm afraid the GUI-Software-Updater still fails. The only way I get him to do anything is via terminal, but that doesn't change my computer being stuck in some weird state. – Dave Sep 18 '13 at 14:08
  • Sure, sorry nothing worked. I found this thread yesterday which mentions a couple other angles. Maybe something in here? http://ubuntuforums.org/showthread.php?t=947124&p=5962046#post5962046 – Lambart Sep 18 '13 at 17:12
  • Thank you very much for your help! Didn't give up and than, after a couple of trials in altering steps, I got it to work! Your code did fix the problem. – Dave Sep 19 '13 at 13:21
  • You're welcome, glad I could help! – Lambart Sep 19 '13 at 18:27
  • 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... – lukewendling Mar 09 '14 at 02: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: https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1343737 – Peter Cordes Jul 18 '14 at 03: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. – Pete Ashdown Sep 10 '16 at 05:34
  • For me, I had to restart after sudo dpkg --configure -a before apt would work at all. – Joshua Grosso Jun 07 '19 at 21:34
  • 1
    @PeterCordes I just hit that issue today in 2021... ‍♂️ – Peter Roberts Mar 09 '21 at 06:21
  • Again, literally the SAME EXACT COMMANDS that are given in hundreds of "solutions" on this site to every problem under the sun, which I have tried dozens of times at this point, literally dozens, for dozens of different problems, and never once seen them accomplish anything at all to solve a single issue. – John Smith Nov 10 '23 at 04:16
  • 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. – Matt Sephton Feb 09 '24 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.

SDQT
  • 111
  • 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 '19 at 00: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 '20 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.

Rayzeq
  • 33
Cédric
  • 181
  • 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 09 '23 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.

Zanna
  • 70,465
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