HOWTO: Create & Use a Separate DATA Partition

gold_finger
  9 years ago
  17

Why create a separate data partition instead of a separate /home partition?

  1. It makes using and sharing data between different operating systems on your computer easier -- whether they are all Linux OS's or Linux combined with Windows.  Instead of having data spread out over each one's separate home folders, they can all read/write data to/from one central location.
  2. Eliminates potential problems when trying to share a /home partition between two or more Linux distros -- where the user program configuration files may conflict with each other.
  3. Makes re-installions, upgrades and switching distros or desktop environments easier.  Just replace the root partition and link back to the untouched data partition -- no need to copy all of your data back on after installation.
  4. Save time if the OS gets broken for some reason, requiring a re-installation.  No need to attempt accessing the OS to copy off data before re-install -- it's already safely off in its own location.

 

Notes on the example used for this tutorial:

  1. Mount points can be anywhere you like, but are typically made under /mnt, /media, or your /home.  This example uses /mnt.
  2. You may name the mount point almost anything you want as long as it doesn't conflict with an already existing filename under that location.  This example will use the name "DATA".
  3. Anywhere you see "yourusername" in a command, substitute your own actual user name in its place.
  4. In this example, the data partition is located at /dev/sda5.  Make sure you substitute the correct location for your partition in its place.
  5. If you want to have a separate /home partition along with the data partition, feel free to do that.  (Some people might want to do that to preserve config files that reside there.  If you do use a /home partition, just remember that it won't need to be more than a few GB's in size if only config files are kept there.)

 

Use GParted from a live Mint DVD/USB to create the partitions for your installation(s).  (You can do it from within the installer also, but GParted is easier.)  Or, use it to make changes, additions, etc. to the partitions you have and to create the data partition.  Format the data partition according to your needs -- eg.  Ext4 if using just Linux OS's;  NTFS if sharing data with MS Windows.  (Here is a GParted tutorial if you need it:  http://www.dedoimedo.com/computers/gparted.html.)

 

(NOTE:  It may be best to copy/paste these commands.  On some it is hard to tell that spaces are between some of the characters and that may cause an error if you mis-type them.)

After partitions are created and you've installed Mint (or additional Linux distro's), create a mount point for the data partition:

sudo mkdir /mnt/DATA

 

Mount the partition:

sudo mount /dev/sda5 /mnt/DATA

 

Take ownership of the mount point:

sudo chown -R yourusername: /mnt/DATA

 

Navigate to the new data mount point:

cd /mnt/DATA

 

Create typical home folders and/or any others you want for the data:

mkdir Documents Downloads Music Pictures Videos

(Note:  I didn't bother with "Desktop" because not typically used to store data.)

 

Find out the UUID# for your data partition:

sudo blkid

 

Open your fstab file and make an entry to auto-mount the data partition on boot:

gksu gedit /etc/fstab

(Note: you may need to substitute a different text editor if gedit not installed to your version of Mint.)

 

In gedit, add either of the two examples below (substitute your UUID# for the ones listed here):

For an Ext4 formatted partition, add these two lines to end of fstab file:

# Mount DATA partition under /mnt/DATA

UUID=ceee2524-7df2-4d21-a1f7-9e7e55c722cc  /mnt/DATA     ext4     defaults     0     2

 

For an NTFS formatted partition, add these two lines to end of fstab file:

# Mount DATA partition under /mnt/DATA

UUID=747D4C9C1EFAD1F2     /mnt/DATA     ntfs-3g     defaults,windows_names,locale=en_US.utf8     0     0

 

Save the changes to fstab and close the text editor.

 

 

Now you have a choice to either use "symlinks" between /home and the data partition, or to "bind" each directory in the data partition to the existing directories in /home.

 

If you use symlinks, delete the existing /home folders that you made duplicates of in the data partition.  (You can't create a symlink of the same name as an already existing folder.)  Copy off any data you want saved in those folders before deleting them.  Then create symlinks for each following this format:

ln -s /mnt/DATA/Documents /home/yourusername

ln -s /mnt/DATA/Downloads /home/yourusername

ln -s /mnt/DATA/Music /home/yourusername

etc., etc....

 

If you bind the directories to home, keep the existing folders in /home because they will serve as mount points using the bind method.  Follow these instructions for binding the data partition folders to your /home folders:  http://forums.linuxmint.com/viewtopic.php?f=42&t=74321.  (Option #3 is probably best -- "Auto Mount at Boot by creating your own Upstart script".)

 

That's it.

Comments
Velcro 2 years ago

Nope. Doesn't work. Bricked my Sudo. Reverting.


Tefa1992 4 years ago

Thanks Alot
it still works, but i had to change gksu gedit /etc/fstab to
pkexec nano /etc/fstab
linux mint 19.3 xfce


IMINOW 5 years ago

Hi - this is a great tutorial, very useful for nubi to duel boot. However could do with an update
All good as far as:

Open your fstab file and make an entry to auto-mount the data partition on boot:

gksu gedit /etc/fstab

(Note: you may need to substitute a different text editor if gedit not installed to your version of Mint.)
-
Text editor now - xed
also
gksu
command no longer recognised (what should I use in 19.2?)

And finally I don't understand the line
Now you have a choice to either use "symlinks" between /home and the data partition, or to "bind" each directory in the data partition to the existing directories in /home.

and any implications of a choice.


bigangry 7 years ago

This helps bigly. Thanks much.


dickheijkoop 9 years ago

Great help to me. Thank you!


neowalla 10 years ago

Thank you!


FLOWXP 10 years ago

could someone help me ?
I'm newbie to this,
I have done this partitioning
5. Gb → Primary → /swap
1.5 Gb → Primary → /boot
50 Gb → Primary → /
100 Gb → Logical → /home
rest Gb → Logical → /Data
but now when I make an Acronis image...it saves double the data, because Data si in / also.
The partitions were made with live CD - XFCE 17, at the beginning of the installation.


Gluonpaul 10 years ago

Perfect I have been looking for exactly this advice to help me set up the new desktop with multiple Linux OS.


DarrenG 10 years ago

Superb, Just what I was looking for. Many thanks