How to Upgrade or Switch Linux Distros Without Losing Data

BY admin May 29, 2020 Let Me Know How! 6 views

When you switch Linux distributions, the default course of action is to wipe everything on your computer. The same is true if you perform a clean install of an upgrade to avoid potential complications.

When you switch Linux distributions, the default course of action is to wipe everything on your computer. The same is true if you perform a clean install of an upgrade to avoid potential complications.

Turns out, it’s actually quite easy to perform clean installs or change Linux distros without losing data. Here’s what to do so that you’re all set up no matter your current situation.

How Does It Work?

What’s the magic that lets you keep all your personal data? Simple: separate partitions.

Whenever you switch Linux distros, you have to tell the installer what partition setup you would like to have on your hard drive. If Linux is the only operating system on the hard drive, you will most likely have one or two partitions. This includes the main partition, usually formatted as ext4, which includes the operating system and all of your data.

Optionally, you can also have an additional partition called the swap partition. This is a portion of your hard drive that’s used as RAM overflow space, as well as the location where RAM data is stored during hibernation.

But you have the freedom to create as many partitions as you like, and you can tell the installer which partitions should be used for which folders.

Creating a Separate Home Partition

20200529.How-to-Upgrade-or-Switch-Linux-Distros-Without-Losing-Data-01.png

If you’re tired of wiping data when you change Linux distros, you want to create an additional ext4-formatted partition. The first one should have “/” (the root folder) mounted to it, and the other partition should have “/home” mounted to it. All of your personal data is stored in the “/home” folder, so that means all of your personal data will be stored in the second partition.

Once you’re ready to switch Linux distros or perform an upgrade, you’re free to wipe out the first partition that contains the operating system and your installed applications. However, the second partition that has all of your personal files and preferences can remain untouched.

Next, when you perform the new Linux installation, you can tell the installer to reformat the first partition (to start from scratch), but leave the second partition alone and just mount it to “/home”. Then, all you need to do is make sure that you set up the same username and password as before, and everything should be back to the way it was.

The only thing you would still have to do is reinstall your applications, but you won’t have to reconfigure many of them because their settings were stored along with your other personal files.

Precautions to Take When Switching Linux Distros

One potential downside is that keeping prior settings while switching between distributions may cause incompatibilities. For example, although Fedora and Ubuntu both use GNOME as the default desktop backend, Ubuntu’s implementation is quite different, and settings from Fedora could get messy. Be aware.

Make sure that when you are giving the two partitions space, you give each of them enough room. If your first, root partition is very small, you won’t be able to install very many applications. If the second partition is too small then you won’t have much room to save your personal files. The partition sizes are hard limits.

20200529.How-to-Upgrade-or-Switch-Linux-Distros-Without-Losing-Data-02.png

I’d suggest giving your first partition at least 15 or 20GB of space if you don’t plan on installing a lot of applications.

If you plan on installing many applications or games (which take up substantial amounts of space), then you may want to go with 50GB. Gamers should look at the games they’re interested in installing and add up how much space each one takes up.

If you find that your partition sizes weren’t appropriate for your usage, you can resize them by booting into a Live environment and running a partitioning tool or using the command line.

Already Have Linux Installed?

If you already have a Linux installation in place and have everything (including your Home folder) on the same partition, don’t worry. It only takes a few steps to achieve the setup you need. The steps are as follows:

  1. Download the Live environment ISO of your favorite Linux distribution, and burn it to a CD/DVD or write it to a USB drive.

  2. Boot into your newly-created media. Use a partitioning tool such as GParted to resize your ext4 partition to the size you want it to be.

  3. Use the same tool to create a new ext4 partition in the empty space created by resizing the first partition. Make note of what partition it is. It should look like /dev/sdXY, where X is a letter designating the drive and Y is a number designating the partition. An example is /dev/sda2.

  4. Mount both partitions, and copy over the contents of the home folder to the new partition. Make sure that you’re copying over all of the contents of the home folder, and not the home folder itself. Otherwise, when everything is done, all of your stuff will be in “/home/home/user”, which won’t work.

  5. Now open a terminal and run the command gksudo gedit to open the Gedit text editor. Now use the menus to open the file located at /etc/fstab in the first partition.

  6. Add the following line to the end of the file: /dev/sdXY /home ext4 errors=remount-ro 0 1. Again, make sure to replace /dev/sdXY with the actual designation for the partition.

  7. Save it, and restart. Make sure to remove the Live environment media so that you boot back into your regular installation.

Switch Linux Distros Without Losing Data

The difference won’t be obvious, but your personal data will now be on a separate partition that stays out of the way when switching distros or performing upgrades!

Separating partitions isn’t only for distro hoppers or to reduce hassle when upgrading to a new release. A separate partition can come to the rescue if you download updates that leave your PC in a state where it doesn’t boot. Simply reinstall a version of Linux on the root partition and you’re back up and running without having to back up and restore a bunch of files.

If you’re now feeling more emboldened to try out other versions of Linux or take a few risks, here’s our list of five bleeding-edge Linux distros. Just make sure to keep regular backups of your personal data, even if it is now on a separate partition.

Comments

write your comment.

Your email address will not be published.