139

I accidentally pressed Ctrl+C during Ubuntu Server's do-release-upgrade process. I'd dropped to a shell to compare a .conf file in /etc/. When I pressed Ctrl-C, it asked whether I wanted to try to reattach to the upgrade process, but it failed to do so.

So I quit, and now there's a hanging dpkg process which is holding onto the apt lock. This is a virtualised server with no GUI frontend...

Is it possible to recover the upgrade process, or do I have to kill the dpkg process and start again?

7
  • 3
    Does screen -list still list the upgrade process? If so, screen -r might reattach it again. What was the exact error when trying to reattach?
    – arjarj
    Commented May 9, 2012 at 18:50
  • I later tried screen -RD, but it didn't work. There wasn't any screen daemon running, so there was nothing to re-connect to. Exact error? I had a choice of 'r' or 'q' I think (reconnect or quit) at the bottom of a curses-like app. Sorry, I can't be more helpful than that. I was using VirtualBox, and without a tmux or screen session running I had no scrollback and the curses-like interface kept clearing the screen. Reconnect didn't work, so I just quit.
    – Alex Leach
    Commented May 9, 2012 at 20:46
  • 1
    I should add that I did try screen -R -D as both sudo user and my normal user..
    – Alex Leach
    Commented May 9, 2012 at 20:48
  • possible duplicate of Ubuntu Server upgrade over SSH hang Commented Sep 13, 2012 at 9:52
  • 2
    Yes! dpkg configure -a is the right answer. That happened to me and the really bad thing was that bind9 was not correctly setup (i.e. the Ctrl-C must have stopped that process and it couldn't start anymore!) Once I fixed bind9 then the apt-get update + upgrade + dist-upgrade ran like a charm and after that I rebooted and it all worked. Commented Oct 7, 2012 at 16:34

3 Answers 3

213
+50

I usually do release upgrades over VPN, so I've tried this a few times. Whenever it updates my openvpn package I lose connection, so I reconnect afterwards.

do-release-upgrade starts a backup SSH session on port 1022 and a backup screen session. If you do not have screen installed this will NOT be available.

You can get the screen session by running:

sudo screen -list
There is a screen on:
    2953.ubuntu-release-upgrade-screen-window   (09/13/2012 04:48:02 AM)    (Detached)
1 Socket in /var/run/screen/S-root.

Then to reattach do:

sudo screen -d -r root/2953.ubuntu-release-upgrade-screen-window

Using the previously listed screen after root/

You should be back to where you lost connection.

7
  • 3
    I dont have screen installed... and i cannot install one with apt-get (file locked)
    – inemanja
    Commented Apr 27, 2019 at 17:18
  • 2
    This is extremely helpful. It might be an even better answer if you just added short mention that do-release-upgrade indeed automatically starts a screen session (you had me reread the question for a second to look for any mention of having started the upgrade process via screen) Commented May 3, 2019 at 6:23
  • 4
    I'm amazed this question keeps getting +1s it's so old
    – Alex R
    Commented May 6, 2019 at 8:39
  • 8
    @AlexR It's still relevan and just saved me today! The magic of Stack* sites! Commented May 24, 2019 at 14:07
  • sudo screen -r is typically enough because typically root is not running any extra screens so connecting to the only one should be okay. Unfortunately the upgrade process launches screen with argument -e \0\0 which disables all keyboard shortcuts in the screen so you cannot detach from the screen with a keyboard shortcut, nor scroll the output backwards. Commented Jul 12, 2023 at 12:15
45

I had the same issue while upgrading to quantal. Unfortunately for me, like the original poster, the screen was killed as well because of ctrl+c.

Killing the dpkg and restarting it with "--configure -a" solved the problem.

Thanks

3
  • bad way killing dpkg, it is better to continue process
    – vlad
    Commented Jan 3, 2020 at 13:51
  • 4
    @vlad if you know how to continue the process, it would be a nice answer on its own. I guess that requires hooking up onto some /dev/pty where dpkg input and output goes, so you can continue answering interactive questions of dpkg. That sounds non-trivial though, so I'd sure give my +1 for an instruction on how to do it.
    – Hi-Angel
    Commented Aug 18, 2020 at 7:17
  • sudo pkill dpkg; sudo dpkg --configure -a resumed it (although this time I had screen installed sudo apt install screen and also ran it in tmux)
    – sunapi386
    Commented Feb 1, 2023 at 4:17
1

I'm more of a CentOS / RHEL person myself but in my experience you're pretty much always better of killing and starting the process over. The downloads, syncs, etc should already be complete and not need to be redone. Since that is what takes the majority of time there shouldn't be much lost going this route.

1
  • Yea, there's not much else that can be done I think. I could probably have used reptyr to reattach to the pty/tty (I never know the difference), but it's easier starting from scratch. And you're right; it's much quicker the second time round!
    – Alex Leach
    Commented May 9, 2012 at 17:48

You must log in to answer this question.

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