Upgrading Ubuntu from Hoary to Dapper

Today, I’ve decided that my old linux box at home really could use an upgrade. I’m currently running Ubuntu 5.04 (Hoary) on it, but I’ve decided to upgrade it to the latest stable version. Of course, I’m sitting at work, connecting into my home network via ssh like normal. Do I really have to go home and pop the cd in the box in order to upgrade? Just how do you upgrade an Ubuntu box anyway?

So, after doing a very brief google search, I’ve discovered that all you have to do to upgrade from one major version to another, is use the same built-in package system you normally use. Pretty cool… but does it work? Since all my data is on the second hard drive, I’m gonna go for it.

According to the instructions I found on Ubuntuguide.org and nixCraft,  there’s just a couple of steps… the key step being replacing all occurrences of ’hoary’ in /etc/apt/sources.list with ‘dapper’. I simplified this into a single command:

sudo sed ’s/hoary/dapper/g’ /etc/apt/sources.list > /etc/apt/tmp && mv /etc/apt/tmp /etc/apt/sources.list

Using sed, we don’t even have to open a text editor, it happens automatically. Now we run the normal upgrade commands that you would use to patch up your system, except now it will upgrade the entire system because we changed the source to the new version.

sudo apt-get update

sudo apt-get upgrade

sudo apt-get -y dist-upgrade

At this point the install process had to download around 500mb worth of updates (not surprisingly) and I’m now watching it install. All of this from a remote location. We’ll see how well it works once it’s done….

Note: It would have been a lot smarter for me to run the upgrade command from within a screen session. Then I could have disconnected, but now I’m still stuck here at work unable to go home, because if I disconnect now, the install process will stop, and most likely my box will be dead.

The install process finally finished up. I’ve rebooted the machine, and everything seems to be operational. That was definitely a great install process!

11 Responses to “Upgrading Ubuntu from Hoary to Dapper”

  1. Johnny Says:

    I should note, you can also use the same method to update from Breezy to Dapper, or from Hoary to Breezy to Dapper, which is probably the safest route.

  2. Luke Plant Says:

    If you had disconnected during the install, it is quite unlikely you would have trashed your box:

    First, everything is downloaded before anything is installed.

    Second, unpacking and configuring of the new packages is ordered sensibly, as far as possible.

    Third, there is no registry or anything like that to corrupt, as each part of the system has its own configuration in a simple text file. Linux systems are very modular — for the most part even fundamental parts of the system (e.g. the init scripts) can be installed or upgraded separately, or even replaced with alternative systems.

    Fourth, the most critical part, the kernel, is often not upgraded, but a new version is installed alongside the original, and the boot loader is then changed to use the new one by default, but you can select the old one at boot time.

    Also, you should remember that you can upgrade a piece of software you are using — the new version won’t be used until the files are reloaded, usually when the program restarts. So you can even upgrade sshd while using ssh.

    If it was still downloading, I would just have done Control-C to cancel it and done it again in a screen session. Downloading would just have resumed from where it was.

    In my experience with Debian boxes, if you try hard enough you can sometimes bork it up enough with a bad upgrade that X doesn’t work. But doing some apt-getting from the console will fix everything. Usually at this point you will have alrady downloaded all the packages needed for the upgrade, it’s just there has been a problem configuring one or something.

  3. Johnny Says:

    Thanks for the tips.. I’ll keep those in mind for future upgrades. I’m thinking of upgrading to Edgy Eft.

    When I got home that day, I noticed that X was completely trashed. After spending some time troubleshooting, I read on a forum that they had released a bug that crashed X if you upgraded. Kinda funny, cause I thought I screwed something up, but it wasn’t even me.

    Thankfully they’ve since fixed that problem!

  4. Patrick Allmond Says:

    How would the average person - the one that everybody is trying to get off of windows - do an upgrade like this? Is there a way to upgrade without dropping into the command line?

  5. Johnny Says:

    Alternatively, you could pop the cd in the drive and run the install off there… just make sure you don’t kill your entire partition.

    You could probably also run the updates from the GUI package manager, but you’d still need to edit that file.

  6. Johnny Says:

    By “that file”, I meant sources.list

  7. Al Says:

    FWIW, “sed -i” edits the file in situ, without need for an output file. This would have saved you a bit of typing as this line:

    sudo sed ’s/hoary/dapper/g’ /etc/apt/sources.list > /etc/apt/tmp && mv /etc/apt/tmp /etc/apt/sources.list

    would have changed to this (adding the -e for execution):

    sudo sed -i -e ’s/hoary/dapper/g’ /etc/apt/sources.list

  8. Johnny Says:

    Al,

    Thanks for that! Saving keystrokes is always useful.

  9. Andrew Says:

    I’ve just jumped from windoze to linux but only had a Hoary CD to go from, your tips worked a treat, you’re a lifesaver, cheers! :D

  10. Wilmer Says:

    Patrick: That’s what I thought too. Fortunately they added a nice “Upgrade to the new release” button to the Update Manager. Don’t know when exactly they added it though.

  11. Another Al Says:

    Patrick: You should check out the upgrade guide at Easy Ubuntu Linux:
    http://www.easy-ubuntu-linux.com/ubuntu-upgrade.html

Leave a Reply