How to Upgrade or Change Linux Distros Without Losing Data

By | April 28, 2022

When you switch a Linux distribution, the default action is to delete everything on your computer. The same applies if you do a clean install of the upgrades to avoid any possible complications.

As it turns out, it’s actually quite easy to do a clean install or change a Linux distro without losing data. Here’s what to do to get all of you to manage whatever your current situation is.

How does it work

What is the magic that allows you to keep all your personal data? Simple: split the partition.

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

Optionally, you can also have an additional partition called swap partition. This is the part of your hard drive that is 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 partition to use for which folder.

Creating Separate Partitions

If you are tired of deleting data when you change Linux distros, you will want to create an additional ext4 formatted partition. The first one should have “http://bintalahe.blogspot.com/” (root folder) attached to it, and the other partition should have “/home” attached to it. All your personal data is stored in the “/home” folder, so that means all your personal data will be stored in the second partition.

Once you are ready to switch Linux distros or make an upgrade, you are free to delete the first partition that contains the operating system and installed applications. However, the second partition which has all your files and personal preferences can remain untouched.

Furthermore, when you do a fresh Linux install, you can tell the installer to reformat the first partition (to start over), but leave the second partition alone and simply mount it to “/home”. Then, all you need to do is make sure that you set the same username and password as before, and everything should be back the way it was.

The only thing you still have to do is reinstall your apps, but you don’t have to reconfigure many of them as their settings are stored along with your other personal files.

Precautions To Take When Changing Linux Distros

One potential downside is that keeping the previous settings when switching between distributions can cause incompatibility. For example, although Fedora and Ubuntu both use GNOME as the default desktop backend, Ubuntu’s implementations are very different, and the setup of Fedora can be messy. Beware.

Make sure that when you give two partitions space, you give each one enough space. If you first, the root partition is very small, you will not be able to install many applications. If the second partition is too small then you will not have much space to store your personal files. The partition size is the hard limit.

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

If you plan to install a lot of apps or games (which take up a lot of space), then you might want to use 50GB. Gamers should look at the games they are interested in installing and add how much space each one takes up.

If you find that your partition size is not suitable for your use, you can resize it by booting into the Live environment and running the partition tool or using the command line.

Linux Is mounted

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

  • Download the ISO directly from your favorite Linux distribution, and burn it to a CD/DVD or write to a USB drive.
  • Boot into your newly created media. Use a partitioning tool like GParted to resize your ext4 partition to the size you want.
  • Use the same tool to create a new ext4 partition in the free space created by resizing the first partition. Make a note of what partition it is. It should look like /dev/sdXY, where X is the letter designating the drive and Y is the number designating the partition. An example is /dev/sda2.
  • Mount both partitions, and copy the contents of the home folder to the new partition. Make sure you copy all the contents of the home folder, and not the home folder itself. Otherwise, when everything is done, all your stuff will be in “/home/home/user”, which will not work.
  • Now open a terminal and run the command gksudo gedit to open the Gedit text editor. Now use the menu to open the file located in /etc/fstab in the first partition.
  • 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.
  • Save, and start over. Make sure to remove the Live environment media so you boot back into your regular installation.

Change Linux Distro Without Losing Data

The difference won’t be obvious, but your personal data will now be on a separate partition which gets in the way of switching distros or upgrading!

Separating partitions isn’t just for the distro hopper or to reduce the hassle when upgrading to a new release. A separate partition can be helpful if you downloaded an update that left your PC in an unbootable state. Just reinstall the Linux version on the root partition and you have your back up and running without having to back up and restore a bunch of files.

If now you’re feeling more adventurous to try another version of Linux or take some risks, here are our list of leading Linux distros. Make sure to keep regular backups of your personal data, even if they are now on a separate partition.

Category: