Choose style:

Author Topic: How To: Use symlinks to a DATA partition  (Read 14600 times)

0 Members and 1 Guest are viewing this topic.

Offline Slim.Fatz

  • Trusted User
  • Veteran
  • *****
  • Posts: 1752
  • Karma: 466
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
How To: Use symlinks to a DATA partition
« on: May 17, 2015, 06:35:00 am »
INTRODUCTION

This is a tutorial that can be used for Peppermint 10 or also the previous versions Peppermint 9, Peppermint 8, Peppermint 7 and Peppermint Six. It is for those who wish to set up their HDD or SSD in a manner that makes it easier to perform several different tasks. Tasks such as:

  • backing up your personal files,
  • installing a new version of PeppermintOS,
  • reinstalling PeppermintOS (in case that is necessary),
  • installing a completely different Linux distribution
This tutorial involves use of the command line interface (CLI) but is still easy for inexperienced users to follow and perform. Note that I use the terms "folder" and "directory" interchangeably (i.e. as synonyms). I also use the terms "CLI window", "terminal" and "terminal window" interchangeably.

The main idea behind this tutorial is to have all of your personal files (meaning: your documents, photos, music, videos, etc.) located on a partition that is separate from the partition(s) used for a typical installation of PeppermintOS. In the remainder of this tutorial I will refer to this separate partition with your personal files as the DATA partition.

To make access to this DATA partition as automatic and transparent as possible we will make use of "symbolic links" -- often also called "soft links" or "symlinks". If you desire more details about symlinks you can refer later to the following informational page that is relatively easy to understand, but unnecessary to complete this tutorial:

http://www.nixtutor.com/freebsd/understanding-symbolic-links/

Note: This tutorial and any changes or deviations from the steps given in this tutorial are done at your own risk. If in doubt or unsure about anything, post your questions here on the Peppermint Forum before doing anything that you might regret. In other words: Look before you leap !!!

Enough said. Let's get started!



SET UP THE PARTITION(S)

I set up my HDD with a / partition (also known as the root partition), where the "distro-specific" files are found, a swap partition (mine is about 2 GB large), and (in an extended partition) a very large partition for storing my personal files (this is the DATA partition). My / partition is about 20 GB in size and the DATA partition is about 250 GB large (I don't have many large video files  ;D ).

Of course there are other possible partitioning schemes you can follow, if you are unsure just post your question on this forum.

If you have already installed PeppermintOS then this DATA partition is one that you must create. It is easy using the Gparted program while running the PeppermintOS live CD or USB (since it is very important that your installation of PeppermintOS is not mounted should you need to make it smaller so that the new DATA partition can be nice and big).

After shrinking your PeppermintOS installation (if necessary) and creating your big new DATA partition (format it as you wish, I use ext4, but you can select ext3, or whatever you prefer and understand), and giving it the label DATA (you can name it something else if you wish) be sure to make a note of where the DATA partition is located. In my setup the DATA partition is the partition known as "device sda5" (its "location") which is written as

/dev/sda5

After noting this information (in this example you would write down

/dev/sda5

somewhere so that you can use it later in this tutorial), you perform the remaining steps while running your installed PeppermintOS.



CREATE THE MOUNT POINT

After booting your installed PeppermintOS and logging into it you will create your mount point for the DATA partition using the following steps:

1. Open your file manager (e.g. Nemo)

2. In the file manager go to the folder /mnt

3. When you have opened the folder /mnt press the F4 key on your keyboard to open a CLI window in this folder.

4. Enter the following command into the terminal window that has opened (Note: Linux is case sensitive! This means that a command like sudo must be typed exactly that way -- Sudo will not work! Neither will MkDir work -- it must be mkdir):

Code: [Select]
sudo mkdir DATA
Hit the Enter key and then type in your user password when asked (Note: your password is entered invisibly. You will not see it. You may enter an incorrect password 3 times before you have to repeat the action you are trying to execute).

5. When you have completed step 4 successfully, enter the following command in the same terminal window:

Code: [Select]
whoami
Press the Enter key and you will see your username printed in the CLI window (just in case you did not know your username already). We will use this username in the next command.

6. After completing step 5, you now enter into the same CLI window (substituting your actual username for "username" in the following command):

Code: [Select]
sudo chown -R username:username DATA
(Note: do not forget the colon : that is inserted between the two occurrences of your username) Hit the Enter key and then type in your user password if asked. The chown command has given you "ownership" of the DATA directory (where the DATA partition will be mounted). Before running that chown command, root was the "owner" and only root would have been permitted to write and delete files there. Not very handy for storing your personal files! But now, since you "own" it, you can do anything there you desire.



MAKE THE DATA PARTITION AVAILABLE FOR USE

Having successfully created the /mnt/DATA mount point you now need to modify the system's file named fstab (found in the folder /etc in the / partition of PeppermintOS). This modification is required so that the DATA partition will always be "mounted" and ready to be used when you log in to PeppermintOS. To do this, use these steps:

1. Open a CLI window (e.g. press the 3 keys Ctrl, Alt and t in the following manner: press and hold down the key Ctrl; while pressing Ctrl now also press and hold down the key Alt; and while pressing those two keys press briefly the key t. This is normally written in the shorthand form as either Ctrl + Alt + t or <Ctrl><Alt><t>, and it will open a CLI window for you).

2. Enter the following command into the CLI window (insert the name of your installed text editor, such as xed or gedit or pluma):

Code: [Select]
sudo xed
Hit the Enter key and then type in your user password if asked.

3. When xed starts, open the file fstab, that you will find in the directory /etc.

4. At the end of the fstab file add the following lines:

Code: [Select]
# DATA partition /dev/sda5 is at /mnt/DATA ...
/dev/sda5   /mnt/DATA   ext4   noatime,defaults   0  0

Note that there is no space between noatime, and defaults! At the end of the second line are the numbers zero, not the letters O. Here you will also perhaps need to replace what I have written as

/dev/sda5

with your actual device name (hopefully you noted it above) where the DATA partition is located. It could be on a different HDD device, such as

/dev/sdb2

Also, if your DATA partition has been formatted to something other than ext4, you must change that in the fstab entry as well. The first line that I listed above (that starts with #) is not really needed (it is just a comment for you to see when you look at this file maybe 2 months later and ask yourself what was I doing here?  :-\ )...

5. After adding the appropriate entry in the file fstab, save the file and close the text editor.

6. To be sure that things are working properly, we will continue in the open CLI window (or, if you have already closed it, open a new one with Ctrl + Alt + t) and enter the command:

Code: [Select]
sudo mount -a
Press the Enter key. If asked, enter your password and press the Enter key again. This command has simply mounted all partitions mentioned in your fstab file, including now the new DATA partition. Now enter the following command in the terminal window:

Code: [Select]
mount
Press the Enter key and examine the output. In the output lines you should be able to see (using the example above) a line that reads pretty much like this:

/dev/sda5 on /mnt/DATA type ext4 (rw,noatime,data=ordered)

If this appears, then the DATA partition is mounted and ready to be used!  8)



MOVE YOUR PERSONAL FILES TO THE DATA PARTITION

In my /mnt/DATA I have created several folders that are named Documents, Videos, Pictures and Music. This can be easily done from within your file manager. Just start the file manager and navigate to

/mnt/DATA

When you are there, "right click" in the opened directory window to get a pop-up menu, where you then select "Create New..." -> "Folder" and then give the new folder a name (such as Videos).

Back in your "home" folder

/home/user_name

(substitute your actual user_name, of course) you should move (not copy, but MOVE) with "cut" and then (in the corresponding folder in the DATA partition) "paste" all of your personal files over to the appropriate folders in the DATA partition: for example, move all files in

/home/user_name/Documents

into

/mnt/DATA/Documents

Do this for all other personal files in the remaining folders, such as:

/home/user_name/Music into /mnt/DATA/Music

/home/user_name/Pictures into /mnt/DATA/Pictures

/home/user_name/Videos into /mnt/DATA/Videos

/home/user_name/Downloads into /mnt/DATA/Downloads

/home/user_name/Public into /mnt/DATA/Public

/home/user_name/Templates into /mnt/DATA/Templates

When this has been completed, you should have all of your personal files in your DATA partition and its folders (i.e. the files are no longer physically in your /home/user_name partition).



CREATE SYMLINKS TO YOUR DATA PARTITION

After all personal files have been moved to the DATA partition, you can start to replace each of the (now empty) folders named Documents, Videos, Pictures, Music, etc. in your

/home/user_name

folder with symlinks to the similarly named folders in /mnt/DATA. Do this as follows (and for each folder):

1. Open your file manager and display your

/home/user_name

folder.

2. Double check that your folder to be replaced (e.g. Documents) in the folder

/home/user_name

is really empty! If it is empty, return to the folder

/home/user_name

2. Delete the empty folder Documents that you see in

/home/user_name

In your file manager, the folder Documents should no longer be visible in the folder

/home/user_name

3.  When in your /home/user_name folder press the F4 key on your keyboard to open a CLI window.

4. In the CLI window enter the following command to create a symlink to your personal files in the DATA partition:

Code: [Select]
ln -s /mnt/DATA/Documents Documents
and press the Enter key. In your file manager you should now see a folder icon with the name Documents and it should have a little "arrow" in one corner (indicating that this is a symlink).

5. "Left click" on the symlink you just created and the file manager should display all of your personal files that you previously moved to

/mnt/DATA/Documents

Now repeat steps 1-5 above for each of the other folders in your

/home/user_name

folder that you have previously emptied of personal files (Music, Videos, etc.). Of course, replace the folder name "Documents" with the appropriate folder name for your next symlink (e.g. Videos).

When you are finished your

/home/user_name

folder looks basically identical to the original, just the folders that are named Documents, Vidoes, Pictures, Music etc. are now symlinks to the actual folders in

/mnt/DATA

Now you just click on one of these "symlink" folders in your "home" folder

Code: [Select]
/home/user_name

and you are automatically shown the contents of the corresponding folder in

Code: [Select]
/mnt/DATA

without having to go there! Adding new files, deleting old ones, etc. within these "symlink" folders in your "home" folder can all be done as before, only everything is now actually occurring in the new folders in the DATA partition and only "appears" to be occurring in your "home" folder. The advantages, I hope, are clear.  ;)

This concludes the work you need to do in this tutorial.



CONCLUDING REMARKS

The advantage to this, as I see and have experienced it so far: When you decide to install a new distro, or new distro version, over the old one, all that you need to do is reformat the / partition (and the /home partition, if you had a separate one) and install over them. Any old and potentially disruptive config files that might have been present in those partitions are now gone (and will be replaced by the new config files of the new installation); however, your personal files in the DATA partition are left untouched! The destruction of the symlinks only destroys the symlinks but not your folders and files on the DATA partition! Of course, you still must recreate the mount point DATA in the directory

/mnt

of the new installation, modify the file

/etc/fstab

as shown above (I always keep a backup of this file in my DATA partition for reference) and make the new symlinks in your fresh

/home/user_name

folder as shown above -- but those few steps are all done relatively quickly compared to backing up all of your personal files, and then later copying them all back to your new installation.

There are other alternatives to this tutorial, for example: using a partition-cloning and -imaging program (like the one AndyInMokum uses -- Clonezilla, as I recall) to backup your personal files -- something that you should probably do anyway in case the HDD with your DATA partition fails! You might wish to read the forum messages from AndyInMokum about this before finally deciding what to do.

An additional note here is that this tutorial is primarily intended for those people using PeppermintOS !! I have not tested it with every possible Linux distro and cannot promise that things will work for any distro other than PeppermintOS. For example, if you use multiple Linux distros to access your DATA partition, there can be problems whose solutions go beyond the goal of this tutorial and are not so easy for inexperienced users to solve. One example of this (although it is thankfully not very common) is if one of your other Linux distros assigns a GUID that is not 1000 (such is the case with the Linux distro PCLOS). To see how you can get around the resulting problems see this forum message by unclebaldie and the one by PCNetSpec that follows it. Thank you, unclebaldie, for bringing up this problem (that I have also had with a different Linux distro -- but I have forgotten which one it was  ::) ) and for showing how it can be solved.

I welcome any comments about and corrections to this tutorial.

In closing, I must say that whatever you think looks easiest for you to do is probably the way to go.

Regards,

-- Slim
« Last Edit: May 19, 2019, 12:56:29 pm by Slim.Fatz »
"Life first -- Peppermint a close 2nd!" -- Zeb

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline rmcellig

  • Member
  • ***
  • Posts: 205
  • Karma: 13
  • New Forum User
    • View Profile
Re: How To: Use symlinks to a DATA partition
« Reply #1 on: June 12, 2015, 04:47:45 am »
I'm going to try this. Excellent tutorial!!!

Thanks Slim!

Offline Slim.Fatz

  • Trusted User
  • Veteran
  • *****
  • Posts: 1752
  • Karma: 466
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
Re: How To: Use symlinks to a DATA partition
« Reply #2 on: June 12, 2015, 04:54:12 am »
Hi rmcellig,


You are welcome! If you have any questions or problems, you know where to come for help!!  8)


Regards,


-- Slim

"Life first -- Peppermint a close 2nd!" -- Zeb

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline Brotherred

  • Member
  • ***
  • Posts: 277
  • Karma: 4
  • No0b
    • View Profile
  • Peppermint version(s): Pep 8 on 386, Pep 9 on AMD 64
Re: How To: Use symlinks to a DATA partition
« Reply #3 on: August 15, 2015, 09:22:58 pm »
Before my most recent install of Pep6, I should have thought to copy my /wine to my /data. If I had done that I would not have had to reinstall all of my of the plug-ins or extensions that go with my Wine applications! E-sword Bible software is one that I have known in the past to easily handle copy and paste or using an old directory and a new install.


My /data drive configuration also is messy. Some how it has always been with Peppermint that my /mnt/data is the label and it is mounted on /media/data. This is the way it is from install time.

Regards
"Those that don't know pay for it. My currency is pride"

Offline Slim.Fatz

  • Trusted User
  • Veteran
  • *****
  • Posts: 1752
  • Karma: 466
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
Re: How To: Use symlinks to a DATA partition
« Reply #4 on: June 25, 2016, 03:57:00 am »
Hi interested readers,

I have done a few cosmetic changes and little updates (related to Peppermint Seven) in the original posting (first message in this thread). I hope you can benefit from this tutorial -- so many people find that it saves them a lot of time and effort when updating, re-installing or adding other distros to test or play around while maintaining access to all of their personal data files.  ;)

As always, if you have any questions then ask back here in the forum and one of us will gladly help you.  8)
Regards,

-- Slim
"Life first -- Peppermint a close 2nd!" -- Zeb

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25455
  • Karma: 2798
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: How To: Use symlinks to a DATA partition
« Reply #5 on: June 26, 2016, 01:10:24 pm »
Thanks for the update Slim .. this is a great tutorial :)
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline Slim.Fatz

  • Trusted User
  • Veteran
  • *****
  • Posts: 1752
  • Karma: 466
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
Re: How To: Use symlinks to a DATA partition
« Reply #6 on: June 26, 2016, 01:45:32 pm »
Hi PCNetSpec,

You're more than welcome, mate. And thank you very much for the accolades *blushing*  :)

Regards,

-- Slim
"Life first -- Peppermint a close 2nd!" -- Zeb

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline Bigoeuf

  • Member
  • ***
  • Posts: 170
  • Karma: 12
  • New Forum User
    • View Profile
  • Peppermint version(s): 8 & 7 (64bit)
Re: How To: Use symlinks to a DATA partition
« Reply #7 on: June 27, 2016, 04:53:43 am »
Yes echo what Mark said - excellent tutorial -  just done a full install of Pepp 7 x64 so it was a good opertunity to do this - went sweet as a nut - the only minor hiccup was in the MAKE THE DATA PARTITION AVAILABLE FOR USE section paragraph 6. I had to reboot & not just logout & log back in again So cheers again Slim  :D

Offline AndyInMokum

  • Global Moderator
  • Hero
  • *****
  • Posts: 4808
  • Karma: 1012
  • "Keep on Rockin' in the Free World"
    • View Profile
  • Peppermint version(s): PM 9 & PM 8 Respin-2 (64-bit)
Re: How To: Use symlinks to a DATA partition
« Reply #8 on: June 27, 2016, 06:05:31 am »
This is a really important tutorial.  Setting up a /DATA partition makes life with Linux much easier and add so much flexibility to the system.  As a community, we need to point it out more often to newbies and upgraders.  Thanks Slim for the PM7 edits  ;).
Backup! Backup! Backup! If you're missing any of these -  you ain't Backed Up!
For my system info please L/click HERE.

Offline Timo

  • Member
  • ***
  • Posts: 163
  • Karma: 37
  • Open Source is more than the sum of its bytes
    • View Profile
  • Peppermint version(s): PM7 Respin (64bit) & PM8 (64bit)
Re: How To: Use symlinks to a DATA partition
« Reply #9 on: June 27, 2016, 07:15:20 am »
As a community, we need to point it out more often to newbies and upgraders.

Yes, absolutly. Everyone with multiple OS or HDDs should know this. Great tutorial Slim!

Offline Slim.Fatz

  • Trusted User
  • Veteran
  • *****
  • Posts: 1752
  • Karma: 466
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
Re: How To: Use symlinks to a DATA partition
« Reply #10 on: June 27, 2016, 08:38:02 am »
@Bigouef:

Thanks for the kind words and the info concerning your need to reboot. I have corrected this postion of the tutorial (it is not necessary to reboot and I should have had this in the original version  ::) ). But at least now it is there.  8)

@Timo and AndyInMokum:

Thank you very much, mates! I really appreciate your words.

Regards,

-- Slim
"Life first -- Peppermint a close 2nd!" -- Zeb

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline donwatson

  • Jr. Member
  • **
  • Posts: 32
  • Karma: 1
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 7
Re: How To: Use symlinks to a DATA partition
« Reply #11 on: June 27, 2016, 06:09:31 pm »
I am going to try this. Will need to have a good read through it first  :-\

Offline AndyInMokum

  • Global Moderator
  • Hero
  • *****
  • Posts: 4808
  • Karma: 1012
  • "Keep on Rockin' in the Free World"
    • View Profile
  • Peppermint version(s): PM 9 & PM 8 Respin-2 (64-bit)
Re: How To: Use symlinks to a DATA partition
« Reply #12 on: June 27, 2016, 06:17:33 pm »
I am going to try this. Will need to have a good read through it first  :-\
This is a great idea and a very nice practical project to do  ;).   After you've done it once or twice, you'll realize how easy it is to do.  It makes life really simple when it come to upgrading, or if you fancy a bit of distro hopping.  Just be sure you back up your critical data before you actually do it.  Also, when in doubt - ask  ;).
Backup! Backup! Backup! If you're missing any of these -  you ain't Backed Up!
For my system info please L/click HERE.

Offline Slim.Fatz

  • Trusted User
  • Veteran
  • *****
  • Posts: 1752
  • Karma: 466
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
Re: How To: Use symlinks to a DATA partition
« Reply #13 on: August 02, 2016, 04:50:45 am »
Hi everyone,

Just to let you know: I have made some small updates and changed a few lines of the original (first) tutorial post to (hopefully) make it easier and more understandable for those new to the concept and interested in giving it a try.

Regards,

-- Slim
"Life first -- Peppermint a close 2nd!" -- Zeb

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25455
  • Karma: 2798
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: How To: Use symlinks to a DATA partition
« Reply #14 on: August 02, 2016, 06:18:52 am »
Nice .. Cheers Slim :)
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec