• Resume a broken ssh connection while `do-release-upgrade` in Ubuntu 10.04 to 11.04

    Posted on May 30, 2011 by in Blog

    Today I decided I had spare time to upgrade my server from 10.04 ubuntu to 11.04.

    I remotely connected to the server through SSH using Putty in Win7 as I typically do, started the do-release-upgrade, and walked away.

    This can be hazardous, for several reasons.

    1) I had not turned on KeepAlives in putty, meaning if the release process needed user input for some reason, putty would timeout after a certain period of time because of inactivity, leaving my installation hanging and without any ability to resume.

    2) If for some reason I lost internet connection (albeit I am on the same switch and this scenario is unlikely, had I been connecting to a remote machine, this scenario is highly probably)

    3) I had not used ‘screen’ to keep my ssh session active and resume-able in case of a disconnect like #1 or #2.

    Upon returning from watching ‘Takers’ (critic fodder for those who enjoy ripping everything apart instead of enjoying things for what they are, but nonetheless an entertaining movie and worth a watch) I saw indeed scenario #1 had occurred and I was presented with a dead ssh session and a partially completed do-release-upgrade.

    Luckily the creators of Ubuntu were nice enough to have the do-release-upgrade process automatically create a screen under the root user (this is a tricky part because `screen -list` without sudo shows no screens to resume). Keep in mind I think this only works if the server has not rebooted since the `do-release-upgrade` process was started.

    To resume my broken ssh connection I reconnected to the server (ssh was still active, if it was not, the `do-release-upgrade` process had also started a secondary ssh connection at port 1022 in case the primary sshd client was terminated in the upgrade process… pay attention to the installation when u first start the process, and Ubuntu clearly states which port the secondary ssh connection is created on — but fails to mention the resume-ability of `sudo screen -list`) and ran the following command `sudo screen -list` and indeed saw there was an existing screen to be resumed.. but how to resume it?

    Thankfully I there is a way, `sudo screen -d -r`

    This allowed the server to detach ‘-d’ from the previous connection, and then reconnect ‘-r’ using my current one.

    The do-release-upgrade took off exactly where it left off (asking if I should allow php.ini to be upgrade, or to keep my existing version) making me, a very happy, and thankful Ubuntu 11.04 upgrader.

    Thank you for this, whomever decided this was a good idea, Canonical Ltd..

7 Responsesso far.

  1. sambarza says:

    do-release-upgrade reconnects to the previous disconnected screen session automatically 😉

  2. dusty says:

    Ubuntu really is coming along quite well.. I’ve not had a chance to use Unity with 11.04 much but I hear good buzz about it.

  3. Jason Rutherford says:

    Ah yes. Lovely Ubuntu. The root cause of excessive dual-booting in my life…

  4. Phani says:

    Didn’t know there was a screen session too! That’s pretty neat.

  5. Paul d'Aoust says:

    Thanks for the tip; I did read the bit about it listening on port 1022, but there was no mention of how to reconnect to it.

  6. axel says:

    Thanks for the advice! Now i can resume my upgrade process.

  7. Dino says:

    Thanks! It worked for me and your blog saved me a lot of trouble and unknown risks.

Leave a Reply

Your email address will not be published.

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