The pain-free guide to switching Linux distros

How to effortlessly swap between distros without losing files

The most recent official count of Linux distros put the number at 'one hell of a lot'.This is good because it gives us plenty of choice, and choice provides freedom and freedom is good, right? Maybe it can feel as if there's a little too much choice at times, but there's no doubt that the huge variety of distributions makes Linux more interesting.

However, trying different distros isn't as easy as experimenting with a new web browser, word processor or even desktop environment.

Switching to a different distro means formatting at least part of your hard disk and starting again with configuration of your system. It could also wipe out all of your personal files, depending on how your disk is partitioned.

You can use a virtual machine like VirtualBox to try new distros, but when you find one you like, it's time to bite the bullet and install it for real. The process of switching distros is largely the same whatever system you want to install, but differences between the way various distros organise themselves mean that there are inevitable variations.

We'll use the transition from Ubuntu Hardy Heron to OpenSUSE 11.0 as an example, but the basic steps are the same with most combinations of distros.

The main drawback of a new installation is that it reformats your filesystems, destroying whatever files were on them. That's fine for the distro itself, but what about your personal files?

The most important asset when switching from one distribution to another is a separate partition for /home. Not only does it prevent your personal files and settings from being destroyed when you're installing a different distro, it also gives you somewhere to save useful information, such as backups of system configuration files.

Without a separate /home partition, you need to back up everything before you start, and you can forget any idea of running a realistic dual-boot system with two distros in use at once.

A /home of your own

While a separate /home partition is a good idea, either when switching or dual booting distros, you should use a different home directory (the /home/username directory) for each distro. This is because some of the settings files in your home directory can be specific to one particular distro, desktop environment or program version and trying to apply them to another can cause problems.

To solve this we use a new directory on the same home partition and copy over only the files we want to share. If you don't already run a separate /home, it's time to divide your programs and data.

Set up /home

As always, when you're messing around with disk partitions and file systems there's a small – but real – risk of losing data. The risk isn't from the software you use; the danger is that the process might be interrupted by a power failure or another piece of software crashing the computer. If in doubt, back up first. Working with in-use file systems should be avoided, too – a Live CD/DVD is best for this, and we'll use the Ubuntu disc.

There are three stages to the process: resize your root partition, create a new /home partition in the space made available and move your data over. It's a lot easier if you have plenty of free space – if your drive is nearly full, move some files to DVDs or an external disk. Then run GParted from System > Administration > Partition Editor.

Partitions can't be resized when mounted, so if a mount point shows alongside the partition in GParted, right-click the partition and select Unmount. When resizing a partition, it's normally only possible to move the end point, so start by dragging the end of the root partition to the left until it's the size you want.