The instructions here cover upgrading Ubuntu droplet from one LTS release to the next one. This was used to incrementally upgrade from Ubutnu 16.04 to 20.04 via 18.04.
Perform standard update
sudo apt-get update
sudo apt-get upgrade -y
Update sources.list
using the nearest repo server (e.g. de
for droplets in Europe, us
in the US, etc)
sudo sed -i 's/mirrors.digitalocean.com/de.archive.ubuntu.com/' /etc/apt/sources.list
Run do-release-upgrade
sudo do-release-upgrade
Revert sources.list
back
sudo sed -i 's/de.archive.ubuntu.com/mirrors.digitalocean.com/' /etc/apt/sources.list
Repeat from the beginning to update to the next LTS version.
Note. Ater 22.04 -> 24.04 upgrade apr sources file moved to /etc/apt/sources.list.d/ubuntu.sources
. This the final change of the sources file should be:
sudo sed -i 's/de.archive.ubuntu.com/mirrors.digitalocean.com/' /etc/apt/sources.list.d/ubuntu.sources