I'm trying to upgrade a Digital Ocean's ubuntu VM from 20.04.6 to 22.04.5 using do-release-upgrade. I'm connected through SSH.
Unfortunately, that's not direct and it's asking me to install all available updates before upgrading.
Before starting, I created a snapshot to quickly recover if anything goes wrong.
While following instructions from this forum, it suggests me to run sudo apt full-upgrade
. After running it and rebooting, the machine refuses connection (which means it entered a state where it's not booting). It doesn't connect even from Digital Ocean's console inside their control panel, let alone through SSH.
After restoring the snapshot, I tried to follow the instructions in this post. After running sudo apt-get dist-upgrade
, I got the same problem after rebooting.
Trying to run sudo do-release-upgrade
without rebooting would download and install the upgrade, but the machine is rendered unbootable at the end anyway.
So, what am I missing here? Any hints?
[UPDATE]
I was able to install all required updates by running sudo apt list --upgradable
and installing each one manually with the sudo apt-get install
, while applying autoremove
when necessary. Now my system is fully upgraded. But when running sudo do-release-upgrade
, after finishing a long upgrade process, the system was rendered unbootable. I even tried shutting the droplet down and turning it on again, but got no success getting it online. I'll restore the snapshot and try investigating further.
After many hours of research, I finally found out the culprit and the solution. The issue in the upgrade is that 22.04 uses netplan, but the 20.04 droplets don’t have any netplan configuration files (at least mine doesn't). So, after rebooting, the machine can't be reached because it's network configuration is gone.
To solve this problem, after running
sudo do-release-upgrade
, when it finishes, answer NO when asked for a reboot. Then get your network info by running:ip a
to retrieve addressesip r
to retrieve routescat /etc/resolv.conf
to get the nameserver configuration.Take note of these outputs, and create a netplan configuration file by running
sudo nano /etc/netplan/config.yaml
and writing the following contents, replacing the corresponding entries for the ones you took note before (and to make things easier, I changed the output's values with letters so you can see where which entry should go):Also, note that yaml content indentation should match exactly as above, or you'll get an error.
Change the newly created file's permission with
sudo chmod 600 /etc/netplan/config.yaml
.Now, run
sudo netplan --debug generate
. If you get a message with something like WARNING:root:Cannot call Open vSwitch: ovsdb-server.service is not running., you can get that solved by runningsudo apt-get install openvswitch-switch-dpdk
, but I think you can ignore that message. I didn't, just in case.Finally, run
sudo netplan apply
and reboot. Note that if you get any SSH keys set, you'll need to reconfigure those, since the singature will be changed.Note that if you go to the /etc/netplan/ folder, you'll notice that there's a file already there, named 50-cloud-init.yaml. Don't do as I did and edit that file with the contents above, because this file's contents do not persist after a reboot and are automatically generated, and I found out when I got locked out of the droplet and had to access it through Digital Ocean control panel's recovery console to create the config.yaml, etc.
I really hope this helps anyone who got stuck on this, and hopefully this can spare you hours of research and headache.