Categories
Uncategorized

[Linux] Recovering a disconnected `apt dist-upgrade` session

Today I was updating my Proxmox install remotely via the built-in console, but forgot what I was doing and closed the tab mid-way.

This resulted in me being unable to connect again as the packages were already being updated in the background and the upgrade has asked a question to replace a file and waiting for my input.

So I could SSH in, but not do anything, as it was still waiting for input on a console that I could not connect to, as it was not opening the UI.

After a quick look around, I stumbled upon a Serverfault thread mentioning using reptyr to take over the terminal session over SSH.

Adding here what exactly was done, to be able the session back and finish the upgrade:

From this comment:

git clone https://github.com/nelhage/reptyr; cd reptyr; make install

This installed reptyr on the machine.

Then I looked for all the open sessions with ps ax | grep pts to find the process I was looking for.

Then I found the parent-most process in the call tree that has pts assigned to it and attached to it via it’s PID:

reptyr -T 1390511

Then I could finish the upgrade! 🎉

Biser Perchinkov's avatar

By Biser Perchinkov

Look, a coder!

Leave a comment