HowTo upgrade from Debian Lenny to Squeeze

This post will show how to upgrade from Debian 5.0.x “Lenny” to the latest stable Debian release 6.0 “Squeeze”. One of the reasons I’ve liked Debian in the first place was the advantage of being able to do a live, in place updates from one major release to another, usually in a safe way. As always, if you do this, please take some time to backup your system if you care of your data, as this is a major upgrade and things can go wrong. Squeeze brings in a few big changes and I will outline some of them, but I would recommend to read the release notes and look for any incompatibilities (hardware or software) or changed things that could affect your particular setup.

1. Update apt sources.list

The first thing we will do (after the backup of course) is to edit the /etc/apt/sources.list file and replace “lenny” with “squeeze“. Originally, this might look like this (for a system using the main US mirrors; your file might use a different local one):

deb http://ftp.us.debian.org/debian/ lenny main contrib non-free
deb-src http://ftp.us.debian.org/debian/ lenny main contrib non-free
    
deb http://security.debian.org/ etch/updates lenny contrib non-free

after replacing lenny with squeeze the file will look like this:

deb http://ftp.us.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp.us.debian.org/debian/ squeeze main contrib non-free
    
deb http://security.debian.org/ squeeze/updates main contrib non-free

2. Perform the system upgrade

After updating the sources file, you will have to refresh the indexes with:

aptitude update

Next let’s manually upgrade the core apt packages (this will pull in some extra dependencies, and this is perfectly fine):

aptitude install apt dpkg aptitude

And finally we will perform the bulk of package upgrades with:

aptitude safe-upgrade

this will take a while depending on what packages you have installed (that will need to be upgraded) and on your internet connection speed.

Here are some changes that you might want to pay special attention during the upgrade:

  • dash: squeeze uses dash instead of /bin/sh as the default system shell. This is the recommended way and it is supposed to be faster and improve the system overall performance. I recommend to use it and accept this change.
  • grub2: is the default in squeeze and the upgrade will recommend to upgrade from your existing grub. This is a major change and for this reason initially the boot loader will be chainloaded in the existing menu.lst to verify it works fine. If you want to upgrade I would recommend to do the chainload and test it with at least one reboot before removing grub legacy.
  • sysv-rc: to improve the boot process the upgrade will offer to move to dependency-based sequencing. This is irreversible but highly recommended. I had no problem with it and don’t see why anyone would not want this.
  • UUIDs: the installer will recommend to switch from regular disk devices (aka /dev/sda*) to disk IDs (aka UUID=c6ecae74-6754-4ad0-986d-98dd9cbfd293) in various configuration places like /etc/fstab, /boot/grub/menu.lst. I personally don’t like that, but didn’t want to take the risk for the device to change its name with the new kernel and went with the change. If you do the same pls. doublecheck the changed files before rebooting.

Now it is time to reboot your system for the first time into squeeze. Fingers crossed and in a few minutes you will be running squeeze (as always an out of band impi console is handy when doing such upgrades)

3. Complete the upgrade

If you upgraded to grub2 and want to remove the chainloaded grub-legacy you can remove it completely from the system with:

upgrade-from-grub-legacy

and the output will look like this:

0
Installation finished. No error reported.
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-5-amd64
Found initrd image: /boot/initrd.img-2.6.32-5-amd64
Found linux image: /boot/vmlinuz-2.6.26-2-amd64
Found initrd image: /boot/initrd.img-2.6.26-2-amd64
done

You can now run:

aptitude full-upgrade

and this will complete some extra packages that were not straitforward and not seen as safe by the normal upgrade process (there might be none, depending on the state of your existing system). Evaluate them before moving forward. And finally once you are done reboot once more (to see that grub2 is working fine by itself) and you will be running the latest uptodate squeeze system.

4. (Optional) Convert your ext3 filesystems to ext4

This step is optional and if you are happy with the ext3 filesystem then you can safely skip it. Myself, I’ve done this most of the time so I thought it might be useful to add it here for anyone else interested to do the same.

First doublecheck if you are running the 2.6.32 squeeze kernel:

uname -a
Linux srv01 2.6.32-5-amd64 #1 SMP Wed Jan 12 03:40:32 UTC 2011 x86_64 GNU/Linux

Older than 2.6.28 kernels (like lenny 2.6.26 for example) don’t have native support for ext4, so this will fail for an older kernel. Because ext4 is backwards compatible with ext3, all we have to do is to change the mount definitions to ext4 in fstab:

vim /etc/fstab

and change the filesystem from ext3 to ext4 for any devices you might have. Make a note on the devices you change, and reboot the machine. After the reboot the machine will use the ext4 driver for the old filesystem even though it doesn’t take full advantage of the ext4 capabilities. To complete this and enable the extra ext4 features we will need to run for each filesystem:

tune2fs -O extents,uninit_bg,dir_index <device>

like, for example for /dev/sda1:

tune2fs -O extents,uninit_bg,dir_index /dev/sda1

this will only be activated when the filesystem is unmounted and we can achieve this with yet another reboot (especially for the root filesystem), and the system will auto fsck them (as the last command marked the filesystem as dirty) and perform the upgrade. I would highly recommend for this to have a remote console on the system as in most of the cases the auto fsck will fail and you will have to run it manually from the console.

Hopefully this howto will help you upgrade your debian system to squeeze with ext4. If you have encountered anything special during the upgrade feel free to share it with others using the comment box bellow.

comments powered by Disqus