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)?

1

3 Answers 3

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 :)

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

5
  • Yeap, that approach, I'm using on Windows, but the main question is should I use /home or it's worth to define my own partition, e.g. /data 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
    Commented Apr 4, 2015 at 13:27
  • Using something other than /home for routine user data is re-inventing the wheel. If you do a lot of distro-hopping, both of the issues you describe are easily handled by using different user home directories, which is most easily done by using different usernames (e.g., trusty and vivid for Ubuntu 14.04 and 15.04), although there are other ways to do it. If you don't distro-hop, the issues you identified never occur. In either case, deviating from the standard means your system is unusual, which can require extra communication and create minor problems when getting help online.
    – Rod Smith
    Commented Apr 4, 2015 at 15:56
  • 1
    But, that's the whole reason why /home exists! There's no reason not to have /home on its own partition. If you don't want a different OS to use it, use a different partition for that OS's /home. I have been using the same /home with no issues on at least 4 different distributions and various versions of each distro. If you don't want that, just use a different username or set a different /home, but do keep /home on its own partition, it makes reinstalling much simpler.
    – terdon
    Commented Apr 4, 2015 at 16:02
  • @terdon New Linux users who are strongly advised to put all their user data on a separate /home partition sometimes come back angry after accidentally overwriting 1TB of not backed up user data while doing manual partitioning in a botched Linux installation. Why didn't anyone warn them about that? I don't think it's wrong in this case to deviate from the standard idea of proper Linux usage provided that I explicitly qualify it as "my own opinion", which I did. I don't think it's reasonable to demand new Linux users like Mike B. to be like Athena who sprang full blown from the brow of Zeus.
    – karel
    Commented Apr 4, 2015 at 17:34
  • @karel well, that's the advice I was given as a new user and it has served me very well. In fact, I have been able to avoid losing data precisely because of this, since I had everything on a separate partition. That way, if you botch your partitions, you might be lucky and not botch the one you have your data on. If you have everything on one partition, then you're screwed. It is far safer to have separate partitions, I'm not saying you're wrong as such (I would have downvoted if I did) I just don't see any benefit in doing it this way and quite a few drawbacks.
    – terdon
    Commented Apr 4, 2015 at 17:44
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .