Here at Swagpile, we came across a situation where we had a server running Debian Lenny (5.0), but there were several packages we needed which were only available in Debian Squeeze (6.0). Unfortunately, the server in question was running on a VPS under Virtuozzo, so upgrading the kernel wasn’t a very realistic option. After poking around online, I determined that this was feasible and that we should go ahead with the upgrade. The first step, obviously, is to back up your existing data. You can use the backup scripts from my previous secure backup article. In our case, it was faster to use the backup facility provided by the Virtuozzo panel. I would also additionally recommend, for convenience, a backup of your /etc directory. You may find yourself having to pull some of your original config files after the upgrade.
tar cjvf etc-backup.tar.bz2 /etc/
Next, you’ll need to make sure your existing packages are up-to-date. Don’t worry if you’re using the backports repo, it should be fine (it worked for us).
apt-get update apt-get upgrade apt-get dist-upgrade
Everything should go smoothly on a functional, production system at least up until this point. Once this process is done, we must resolve any lingering configuration issues in lenny before moving on. We do this by issuing the following commands:
dpkg --audit dpkg --get-selections | grep hold
This is where things can get a little hairy. To upgrade safely, no packages can be waiting to be configured or on hold. Running
dpkg --configure -a
took care of most of our issues, but we got into a dependency loop from hell with the MySQL 5.1 server packages where we had to manually upgrade the MySQL databases and basically trick dpkg into continuing the install. This won’t happen if you’re running vanilla Debian Lenny, though; we were using packages from dotdeb.org. Once we fixed the database tables and whatnot, purging the dotdeb.org package, removing the repo from our sources.list file and installing the official Debian Lenny MySQL package worked. After we finished the whole upgrade, we put the dotdeb repos for Debian Squeeze in our /etc/apt/sources.list.
Once you’ve worked all that out and you’ve upgraded cleanly to the latest package updates lenny has to offer, it’s time to upgrade to squeeze. Edit your
/etc/apt/sources.list file as follows:
deb http://ftp.se.debian.org/debian/ squeeze main contrib non-free deb-src http://ftp.se.debian.org/debian/ squeeze main contrib non-free deb http://security.debian.org/ squeeze/updates main deb-src http://security.debian.org/ squeeze/updates main
Don’t muck around with trying to install new kernels or grub or anything, it’ll probably end badly. As long as you’re running 2.6.18(ish)+, everything will be fine. Also, be advised that if you’re running an older kernel, you’ll be informed that the dependency-based boot system can’t be installed. Don’t panic, everything will work just fine. Just go ahead and run
apt-get update apt-get upgrade
This may take a while. Be careful when prompted for configuration and when asked to replace existing config files. ALWAYS check the diffs! I recommending tending towards keeping the new files and hand-merging files from your backups when the files have more than a few lines to change.
Once that’s all done, run
to finalize the upgrade. Follow the above advice about the configuration, and be glad you took my advice to back up /etc!
Once you’re done getting your configuration files in order, you’re done! You can reboot at this point just to make sure all the services are restarted and that everything works on a fresh boot, but this should not, in theory, be necessary.