Open Source

Upgrade Ubuntu with apt-get for a smoother transition

I recently discovered a few servers still running on Ubuntu 5.10 ‘Breezy Badger,' which officially had its support withdrawn in April of this year. Now, it's certainly not a good idea to have any server running without security updates available on tap. While it would be easier to take the approach of "if it's not broken don't fix it," the risk of being compromised by a known and patched security flaw is unacceptable — time to upgrade!

Now I don't know about everyone else, but I'm always wary of patching and upgrading Linux installations. With Windows, it's easy; double-click to launch the update, click on OK a few times, and after a reboot, everything's up to date and most importantly, it still works. With Linux (as should be expected), it never seems to be quite that easy. Updating packages like Apache, Samba, and OpenSSH is usually trouble-free, but when kernel and library updates are required, it can be a different story.

In the past, I've had a server refuse to boot after running SUSE's YaST online update; this has made me inherently cautious when it comes to upgrading core components. In that particular instance, the problem was due to the updated kernel not allowing the old(er) HP SCSI driver module to load. Luckily, this particular problem was flagged during the initial server build and update process, so there was no harm done.

With the precariousness of that update in mind, I set about finding the lowest risk way of upgrading Ubuntu from one release to the next — something that's akin to upgrading Windows 98 to XP, XP to Vista, and so on.

After a bit of digging around for opinions on the best way to upgrade Ubuntu, I found two schools of thought: One was to use aptitude and the other was to use apt-get. Both of these package managers deal with the many underlying dependencies between software packages, libraries, and modules. While browsing several articles on Digg I came across this one: "Aptitude vs apt-get." It looks like Aptitude should be the preferred tool given comments like, "Aptitude is the superior way to install, remove, upgrade, and otherwise administer packages on your system with apt." And the summary, "Aptitude is just superior to apt-get in every way, shape, and form. Better dependency handling. Better curses application. Better options."

That taken in to account, I've used apt-get since first making contact with Ubuntu back in 2004, so I wasn't going to ditch it based on one report alone. I did the sensible thing and searched the official Ubuntu Web site for the word upgrade; funnily enough, it came up with some useful information. It seems apt-get is the recommended tool for an Ubuntu distribution upgrade; Aptitude is recommended for Debian distribution upgrades. While Ubuntu is based on Debian, it would be prudent to follow the official upgrade procedure.

Once I'd worked out the best way of upgrading my Ubuntu distribution, I needed to decide which version I wanted to upgrade to. At the time of writing, currently supported distributions are: 6.06 LTS Dapper Drake (Long term Support), 6.10 Edgy Eft, and 7.04 Feisty Fawn. Seeing as I'm upgrading a server and want as little disruption as possible in the future, 6.06 LTS is by far the best option. Dapper Drake's support runs until 2011 (for servers), which is three years after Feisty Fawn's support runs out. Add to that the fact that upgrades must be made from the previous release — meaning that if I wanted to upgrade to 7.04, I would first need to upgrade 5.10 > 6.06 > 6.10 > 7.04. Sticking with 6.06 Dapper Drake is therefore a no-brainer for me — supported for longer, less work to upgrade.

Once underway, I was actually surprised at how painless the upgrade process was. Don't forget to run through this update on a test machine before trying it on your production box. It may sound over cautious to some but it's always the best practice and can avoid unnecessary issues later on (when it's too late to turn back)! I'm upgrading from 5.10 to 6.06, but the process will be identical for other versions. If in doubt, check out the official documentation.

1. If both xscreensaver and gnome-screensaver packages are installed you must remove xscreensaver to avoid some dependency conflicts:
# apt-get remove xscreensaver

2. Backup and edit /etc/apt/sources.list:

# cp /etc/apt/sources.list /etc/apt/sources.list.breezy
# nano /etc/apt/sources.list

Edit each repository entry replacing breezy with dapper; for example:

deb http://gb.archive.ubuntu.com/ubuntu breezy-updates main restricted

Becomes:

deb http://gb.archive.ubuntu.com/ubuntu dapper-updates main restricted

3. Update the package lists:

# apt-get update

4. Launch the upgrade:

# apt-get dist-upgrade

It's important to use ‘apt-get dist-upgrade' rather than ‘apt-get upgrade' as the former will only upgrade some packages; those with uninstalled dependencies will not update, leaving your system stuck somewhere between the two releases.

Keep an eye on the terminal during the upgrade as some packages may require your attention. My installation was running Apache, PHP, MySQL, and Nagios; only MySQL required some input which was just to tell it to keep its current configuration.

It's a good idea to check the official documentation before completing your upgrade as there may be some additional tasks required before rebooting. For the 5.10 to 6.06 upgrade, I needed to reinstall mesa-common-dev package due to some known issues in the upgrade process:

# apt-get install —reinstall mesa-common-dev

After this, I rebooted and kept my fingers crossed. The system came back up with no error messages in the logs. To check that the upgrade has been successful:

# cat /etc/issue
Ubuntu 6.06.1 LTS n l

Success... My older Ubuntu servers are now up to date and won't need upgrading until 2011, hooray!

Editor's Picks

Free Newsletters, In your Inbox