5

Where to store the user data, such as documents, photos, music, videos, ebooks etc. in Linux? The main idea is to be able to reinstall & reformat the system drives in Linux without the fear of personal data (MP3, JPGs, PDFs etc., not user config files) loss.

I plan to explore the Linux, so I suppose, it may become ruined quite frequently, so I need to be able to completely reinstall the system without the problem of personal files.

There is a similar topic: «Super users and the home directory», but this topic is so verbose and doesn't return a concrete answer. The main questions are:

  1. Should I use /home or it's worth to define my own partition, e.g. /data?

  2. And if I define my own partition, how to assure that each time I reinstall OS my own partition is accessible (automatically mounted and ready-to-use without deepening into configs)?

Mike
  • 443
  • 2
  • 11
  • 19

3 Answers3

4

Data should be stored in a different partition of the file system of your OS. In Linux, personal data is stored in /home/username folder. When you run the installer and it ask you for partition your hard disk, I suggest you to create an extended partition for the home folder.
If you need to format your computer, you only have to do it with the primary partition.
I attach you a screenshot of the Gparted utility; it shows my disk.enter image description here When you reinstall an OS and you already got a home folder, you will necessary need to create a new home for the new user and link or move (carefully) all the files of the old folder to the new folder.

UPDATE
From my experience, having an exclusive partition for your /home (Linux) or D:\ (Windows) is better. Both in Windows and Linux, in your data folder, will create some files (mostly hidden files) that could give you some problems if you don't be careful while you move the old files to the new folder (if you reinstall the OS).
I have reinstalled five times my Linux keeping my personal data untouched and I share it with my Win7 with no problems :)

verovan
  • 162
3

Store the user data on a separate partition from the operating system. If you are careful not to overwrite this partition when reinstalling the operating system, this data will be safe. For example, if your computer has two hard drives, an SSD and an HDD, put the operating system on the SSD and the user data on the HDD.

My opinion is that it is better not to have a separate /home partition for two reasons:

  1. When reinstalling the operating system, some files in the /home directory are overwritten, but your user data will not be affected if it is in a separate partition.

  2. Frequently used files such as configuration settings and virtual machine images can be stored in the /home directory where they can be accessed more quickly if the /home directory is located on an SSD.

The data partition can be made accessible by automatically mounting it when the operating system starts up. This is done in Linux by editing the /etc/fstab file and adding a new line to it containing information about how the partition that you want to be automatically mounted at startup should be mounted into the filesystem.

You can use custom folders for folders in /home/. Example:

 xdg-user-dirs-update --set DOWNLOAD /media/user/Downloads/

would switch from /home/$USER/Downloads/ to /media/user/Downloads/ and documents downloaded would then download to the HDD and not the SSD. The same applies for all the other directories. See ~./config/user-dirs.dirs on manually editing these settings.source

karel
  • 13,706
1

Making an educated guess here, you are looking for an easy solution to your problem

Don't put too much stress on creating another partition, but this is dependant on your situation

When you install your distribution of choice ensure that your disk/partition has been zero-ed out, as in a full format, this can also be achieved through "dd if=/dev/zero of=/dev/sda1", sda1 being your disk or partition of choice, you may acheive similar results with a command like "dd if=/dev/zero of=/home/user/zeros", this will ensure unused space does not contain any data

Install your distribution, set it up the way you want

Using your installation media, you will want to make a disk image, the previous command will help you reduce space use by your backup, this can be done like this "dd if=/dev/sda1 | bzip2 | dd of=/path/to/backup" with the backup being on a seperate disk/partition When you need to restore your said backup just reverse the above command and replace bzip2 with bunzip2

These instructions will not work "out of the box" but it shouldn't be too difficult to understand them if you take your time to read them

You may wish to consider reading and completing linuxfromscratch, it will help you a great deal

Steve
  • 111