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
@smoothback
Copy link

smoothback commented Feb 8, 2018

I was getting the same issue when connected via SSH. You can either install x11vnc, start vnc via ssh, then remote in that way; or install xrdp, then remote in from windows remote desktop, or remmina from another linux machine. Hopefully that helps.

Upgrade from 15.04 to 15.10 worked as expected, going from 15.10 to 16.04 was good too.

This worked perfectly for me! Saved me a couple hours of driving, re-installing, and re-setting up software. Good stuff!
Lesson learned, always use the LTS releases for servers, don't leave your stuff unpatched for too long.

@ChandanKumarSahu
Copy link

It was really helpful.
Can you explain some of the lines .

@blakethepatton
Copy link
Author

@ChandanKumarSahu
First line you're backing up your package lists (in case something goes wrong and you want to go back to using them)
Second line swaps out all the instances of archive.ubuntu.com and security.ubuntu.com with the old-releases.ubuntu.com inside of your package lists.
Third line updates and upgrades

Then you're grabbing wily which is I believe the upgrade scripts' name, and then uncompressing it.
Next we switch wilys' references to ubuntus update servers to the old releases server like we did on line 2.

And then we execute wily.
If I remember correctly, it 404's because it has the archive and security package lists cached somewhere, and then it asks if it should update those lists. (Again, if I'm remembering correctly)

Finally, it's done. And I think it asks if we want to restart. Which, of course we do. If it doesn't ask you can just run sudo shutdown -r now

We boot into 15.10.

Once again I backup my package lists ~ better safe than sorry.

We update the package list and then upgrade the installed packages. At the time of writing there was an upgrade path from 15.10->16.04 have an upgrade path to 16.04. So we can do it the proper way through the dist-upgrade command. However, eventually that upgrade path will be archived like from 15.04->15.10 and the automatic upgrade won't work. But hopefully this'll be helpful enough to help that person figure out what they've got to do in order to get to the next version of ubuntu.

@zhangjl
Copy link

zhangjl commented Mar 3, 2018

26
25
I get the error where I upgrade my Ubuntu 15.04 to 15.10, the picture show "package sign error", but I don't kown how to resole it

@blakethepatton
Copy link
Author

@zhangjl I'm not sure how to fix that problem, if you're wanting to restore your package lists to how they were you can always revert them by copying them back sudo cp ~/sources.list /etc/apt/sources.list but I don't think that'd fix the package signatures. If it were me, since it looks like it's only two packages, I'd just re-install them after the install was successful.

@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