When you change your Linux distribution, the default is to wipe all parts of your computer. The same is true if you run the upgrade to avoid possible complications during a clean installation.
It turns out that it’s really easy to perform clean installations or change Linux versions without losing data. Here’s what to do so you’re all ready no matter what your current situation is.
How does it work?
What magic allows you to keep all your personal information? Simple: separate sections.
Each time you switch in the Linux distro, you need to tell the installer which partition settings you want on your hard drive. If Linux is the only operating system on your hard disk, you probably have one or two partitions. This includes the main partition, which is usually formatted as ext4, which contains the operating system and all your data.
Optionally, you can also call an extra partition exchange-section
What is a Linux Swap Partition? Everything you need to know
. This is part of the hard drive that is used as the RAM overflow area, as well as the location where the RAM data is stored during hibernation.
But you have the freedom to create as many partitions as you want, and you can tell the installer which partitions should be used for which folders.
Creating a separate home partition
If you’re tired of wiping data when modifying Linux disks, you’ll want to create an extra ext4-format partition. The first should have “/” (root directory) installed on it, and the second partition should have “/ home” installed on it. All your personal information is stored in the “/ home” folder, so all your personal information is stored in another partition.
When you are ready to replace the Linux disks or perform the upgrade, you can erase the first partition that contains the operating system and installed applications. However, another partition that has all your personal files and settings may remain intact.
Next, when you perform a new Linux installation, you can prompt the installer to reformat the first partition (start from scratch), but leave the second partition alone and install it only in “/ home”. Then all you have to do is make sure you set the same username and password as before, and everything should go back to the previous way.
Separating partitions doesn’t stop you drive encryption
4 reasons to encrypt Linux partitions
The only thing you still need to do is reinstall the applications, but you won’t need to reconfigure many of them because their settings are saved with your other personal files.
Precautions when replacing Linux Distro
One potential drawback is that keeping previous settings when switching between distributions can cause incompatibilities. For example, although both Fedora and Ubuntu both use GNOME as the default desktop program, the implementation of Ubuntu is quite different, and Fedora’s settings can be messy. Beware.
Make sure that when you give space to the partitions, you give everyone enough space. If the first root partition is very small, you will not be able to install very many applications. If the second partition is too small, you won’t have much space to store your personal files. Partition sizes are hard limits.
I suggest giving your first partition at least 15 or 20 GB of space if you are not going to install a lot of applications.
If you plan to install many applications or games (which take up a lot of space), you may want to use 50GB. Players should look at the games they are interested in installing and add up how much space each takes up.
If you find that the partition sizes were not appropriate for your use, you can resize them by launching the Live environment and running the partitioning tool or using the command line
Use these 10 fdisk commands to control Linux partitions
Is Linux already installed?
If you already have a Linux installation in place and you have everything (including the Home Folder) on the same partition, don’t worry. It only takes a few steps to complete the required installation. The steps are as follows:
- Download your favorite Linux distribution Live Environment ISO and burn it to a CD / DVD or burn to a USB drive.
- Launch in newly created media. Use the partitioning tool, such as GParted, to resize the ext4 partition to the size you want.
- Use the same tool to create a new ext4 partition in an empty space that is created by resizing the first partition. Make a note of which partition it is. It should look like / Dev / sdXY, where X is a letter indicating the drive and Y is a partition number. An example is / dev / sda2.
- Install both partitions and copy the contents of the home folder to the new partition. Make sure you copy the entire contents of the home folder and not the home folder itself. Otherwise, when everything is done, all your stuff is in the “/ home / home / user” covers, which doesn’t work.
- Now open the terminal and run the command gksudo gedit open the Gedit text editor. Now use the menus to open the file located at / Etc / fstab in the first section.
- Add the following line to the end of the file: / dev / sdXY / home ext4 errors = remount-ro 0 1. Again, make sure that / dev / sdXY is replaced with the actual name of the partition.
- Save it and restart. Make sure you remove the Live environment to start back to the normal installation.
Replace Linux Distrot without losing data
The difference isn’t going to be obvious, but your personal information is now in a separate section that stays out of the way when you switch distros or perform upgrades!
Partition separation is not just in distro funnels or to reduce the hassle of upgrading to a new version. A separate partition can come in handy if you download updates that leave your computer in a state where it won’t start. Just install a version of Linux on the root partition and you are backed up and running without having to back up and restore a bunch of files.
If you feel more courageous now trying other versions of Linux or taking some risks, here is a list five high-end Linux distros
5 Linux operating systems that provide an upgrade
. Just make sure you keep regular backups of your personal information, even if it’s now in a separate section.