Skip to content

Instantly share code, notes, and snippets.

@blakethepatton
Last active April 13, 2023 13:18
Show Gist options
  • Save blakethepatton/196e593999e4e8630d364bad3a076deb to your computer and use it in GitHub Desktop.
Save blakethepatton/196e593999e4e8630d364bad3a076deb to your computer and use it in GitHub Desktop.
Upgrading ubuntu 15.04 to 15.10 and to 16.04
sudo sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
sudo apt-get update && sudo apt-get dist-upgrade

mkdir wily && cd wily
wget http://old-releases.ubuntu.com/ubuntu/dists/wily-updates/main/dist-upgrader-all/current/wily.tar.gz
tar -xzf wily.tar.gz

sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' Ubuntu.info
sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' Ubuntu.mirrors

sudo ./wily

Upon running this on another host I got "ImportError: No module named 'apt' just install it:

Either:

apt-get install python-apt -y

sudo apt-get install python3-apt --reinstall <- This worked for me.

Gets a bunch of 404's and then asks if it should overwrite the sources.list Y

Try not to kill ssh if you're connected via ssh... Wait patiently and hope everything works...

restart

Should be on 15.10

cd ~
mkdir 

cp ~/sources.list ~/sources-backup.list
cp /etc/apt/sources.list ~/sources.list

sudo apt-get update && sudo apt-get upgrade
sudo do-release-upgrade

go through the upgrade, hope everything works...

Things are going to be removed, I just removed them all, I'll add back whatever I need later

restart the server again

should be on 16.04.3

sudo apt-get autoremove
@EnMaster
Copy link

Thank you for the script! Today I managed to update an old VPS still stuck in 15.04 (ridiculous!).
A piece of advice: if there are active third-party source lists that may not be able to connect due to expired certificates, it would be better to disable them so as not to give errors during the version upgrade process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment