Recovering from a lost connection when upgrading Ubuntu via ssh

I wanted to upgrade my desktop machine at work to the latest version of Ubuntu, but since it takes several hours to upgrade an Ubuntu host, and I have work to do during the day, I figured I could log into my workstation from home in using ssh and start the upgrade remotely.

So I logged into my workstation from home and ran:

> sudo apt-get install update-manager-core
> sudo do-release-upgrade

The upgrade script warned me that I was using ssh and asked if I was sure I wanted to continue. I said “Y”, and a little while later the upgrade manager was busy downloading upgrade packages.

I planned to check it a couple of times that night, answer any package upgrade questions that popped up, and then in the morning when I got to work the upgrade would be complete.

Of course what actually happened was that I got side-tracked onto some other problem that night, forgot about the upgrade in progress, and when I got to work the next day my workstation was in a state of limbo, with the upgrade halfway complete, waiting for me to answer some question on the screen — at my house.

Luckily the Ubuntu developers who created the ssh upgrade process run that upgrade inside of a screen session. As the screen pages states, “Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).”

So at work all I had to do was get the list of current screen sessions:

> sudo screen -list
There are screens on:
        9129.ubuntu-release-upgrade-screen-window       (05/17/2011 08:50:08 PM)        (Attached)
2 Sockets in /var/run/screen/S-root.

Invoke screen using the “-d -r sessionowner/[]” flags:

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

… and I could pull up the screen at work that had been displaying at my home. Once I answered the remaining questions about whether to keep my custom configuration files or use the new, packaged configuration files my workstation rebooted and the latest version of Ubuntu booted right up.

17 thoughts on “Recovering from a lost connection when upgrading Ubuntu via ssh

  1. This was incredibly helpful. I was looking around to figure out how to access this screen and you explained it perfectly.

  2. Pingback: Melanjutkan Upgrade Ubuntu via SSH : Tempias Pikir

  3. Saved my life here: I knew there was SOME reason why I was not to shut down my laptop and take it with me when I left work, and about a half hour ago I remembered why :(

    and y’know, when searching for common words like ‘upgrade’ or ‘screen’ google really isn’t much help; fortunately I remembered the screen program would be running and just did a search on the command line of the running process to end up here.

    it is a nifty little trick actually — I guess that’s why it’s here — and it may be I might never again waste time hanging around for an install to finish, I’ll just pick it up whenever!

  4. Thank you, helped me when I lost the terminal during a local upgrade (windowmanager dying).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.