Upgrading an OpenVZ VPS from 12.04 to 14.04

I’ve recently gotten tired of dealing with old packages like Apache 2.2, and decided it’s time to take the plunge and try to upgrade Ubuntu on my VPS. I approach this with much trepidation; as the last time I tried something like this, I ended up with a VPS that needed to be reinstalled from scratch.

Preparation

The first thing I did was hit my VPS provider’s support IRC channel and ask for some guidance in there. I got some mixed answers – one of the admins suggested to just clean-install, since he’d seen a lot of customer issues resulting from doing these upgrades. Another user in the chat (who seems very knowledgeable – even more so than I) suggested it was possible with do-release-upgrade -p. Other users had other suggestions, but the one thing they all had in common, was make backups. So, I devised a battle strategy…

Procedure

  1. Update my backups. This meant re-running my backup scripts that dump my databases, and then have Crashplan do a backup. Did you know you can run Crashplan on a headless system?
  2. Start a serial console. do-release-upgrade can kill your SSHD and completely hose a system, so I used my VPS control panel to start a serial console, and connected to that.
  3. Cross your fingers, take a shot of whiskey (kidding, alcohol and root don’t mix), and do-release-upgrade -p, and wait…
  4. While the process is running, take notes of what it tells you onscreen. I had to upgrade a postgresql cluster, which would have been annoying had I not read the instructions about pg_dumpcluster and pg_upgradecluster. Also, pay attention when it asks you about keeping/overwriting configuration files. I didn’t pay close attention to changes in /etc/apache2/apache2.conf and was confused for a little when my sites weren’t coming up. More on that later.
  5. Reboot when it asks, and pray to whatever deity you subscribe to that nothing is broken.

The Aftermath

Can you connect via SSH like you used to? Good job, your baby in the cloud is more-or-less still breathing. Most of your apps have probably gone down though. Do an extensive test now. Here’s what I did, and the problems I encountered.

  • Verify my iptables configuration. Just iptables -vL and make sure everything looks the same. Just in case. In my case, everything was fine here.
  • Do any post-install steps the installer told you to do. For me, this meant (as the postgres user) pg_dumpcluster 9.3 main to get rid of the empty 9.3 cluster the upgrade put there, then pg_upgradecluster 9.1 main to upgrade the cluster. After testing, pg_dropcluster 9.1 main and service postgresql restart. Not too bad, though everyone’s heart skips when hitting enter on pg_dropcluster. You DID make backups, right?
  • Test your applications. I uncovered quite a few things I needed to do, such as bundle install --system on all my rails apps, since the version of Ruby changed, and thus, my gem path. Also had to fix some PHP apps due to a change in PHP on 32-bit Ubuntu systems. Also, Apache sites now have to end in .conf to get picked up by a2ensite. I found this out the hard way, by not diffing the changes in /etc/apache2/apache2.conf, figuring I didn’t need to, as I never modified that file.

Done

Once you’re satisfied that everything is OK, close your SSH session, and go enjoy that shot of whiskey I mentioned earlier.

Leave a Reply

Your email address will not be published. Required fields are marked *