Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

I am still newbie to ubuntu.

I have a partition (ext4) with all my Documents and Photos, etc. This partition doesn't have any mount point. I want to use Document folder from this partition as my Document folder in Home directory.

I see few possibilities, somehow to mount this partition on booting (and not when I click on it in Folder Manager) and create symbol link from my /home/Documents to /media/partition/Documents or just mount all partition as /home/Document.

It seems like the first solution is cleaner, however the problem is I don't really understand how to mount partition on booting to constant media folder.

What's is the right way to do so?

share|improve this question

marked as duplicate by Eliah Kagan, belacq, Radu Rădeanu, Eric Carvalho, AgentCool Aug 2 '13 at 15:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
If you have documents, photos, etc. on that partition, then you should go with the first option (automount it, and symlink the Documents folder). To proceed, we need to know the partition (sda#) or its UUID. What is the output of sudo blkid? And which partition is it? –  Alaa Ali Jul 30 '13 at 8:14
    
@Alaa, thank you for the comment, it's sda3 and ext4. –  tam Jul 30 '13 at 8:43
    
Since Danatela posted an answer, I'll post an answer utilizing a slightly more graphical way. –  Alaa Ali Jul 30 '13 at 9:36
    
Scratch that, the method I was going to post is available on 12.10+, while you're on 12.04. I'll post an answer that directly gives instructions. –  Alaa Ali Jul 30 '13 at 10:21

2 Answers 2

up vote 1 down vote accepted

First, copy everything you have in your current (Home folder) Documents folder over to that partition.
Second, I'm going to assume that there is a folder called "Documents" in that partition.

  1. sudo umount /dev/sda3

    • This is to unmount the partition if it's already mounted.
  2. sudo mkdir /media/partition

    • This will create our mount point.
  3. sudo cp /etc/fstab /etc/fstab.bak

    • This will take a backup copy of the file we're going to edit.
  4. sudo nano /etc/fstab. This will open up the file in a text editor. Navigate to the end of the file, and paste the following two lines (paste by Ctrl+Shift+V):

    #automounting the sda3 partition to use for Documents
    /dev/sda3   /media/partition           ext4    defaults        0       2
    

    When done, hit Ctrl+X, then Y, then Enter to save and close.

    • The second line ensures that sda3 is always mounted to /media/partition. The defaults option is the one responsible for auto-mounting, amongst other things. Read more here: Fstab - Community Ubuntu Documentation.

    A more robust method would be to replace /dev/sda3 with UUID=<randomnumbers> in the second line, that's why I asked you for the output of sudo blkid in the comments.

  5. sudo mount -a

    • This will make our changes to fstab take effect. If you get errors here, stop!
  6. cd ~ && rm -r Documents

    • This will delete the Documents directory in your Home folder.
  7. cd ~ && ln -s /media/partition/Documents

    • This will create a symbolic link to that Documents folder in the partition.
  8. At this point, you're done. However, you'll probably notice that your Documents folder has lost it's properties, and looks like this: and not like this . To fix this, do nano ~/.config/user-dirs.dirs and re-add the path to Documents in its respective line:

     XDG_DOCUMENTS_DIR="$HOME/Documents"
    

    Ctrl+X, then Y, then Enter to save and close. Re-open Nautilus (your file manager) and you should be set.

  9. Test by rebooting your machine.

Since you've mentioned that you also have Pictures(, etc.) on that partition, you can repeat steps 6, 7 and 8 to create their symbolic links, but remember to backup whatever is in the current folders.

share|improve this answer

To have partition with documents automounted during boot, you should have partition entry in your /etc/fstab file. Let me assume that you have / on /dev/sda1, swap on /dev/sda2 and Documents partition on /dev/sda5. Then your /etc/fstab should look like this:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#                
# / was on /dev/sda1 during installation
UUID=b632398e-9f06-46f7-8fe9-3e61266354a6 /               ext4 notail          0       1
# swap was on /dev/sda2 during installation
UUID=b1585d95-2256-474d-87ba-ed797c7b8845 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0

To make Documents partition automount during boot, you have to add such entry there:

/dev/sda5 /mnt/Stuff  ext4 defaults,uid=1000,gid=46          0       0

If you have UUID of /dev/sda5, it is preferrable to put UUID= instead of /dev/sda5 on the first position. uid and gid are numeric IDs of your user account (usually 1000) and group plugdev (always 46). You can omit these options since defaults already contains needed permissions.

Now, when your drive is mounted, you can make symbolic link to your documents:

mv ~/Documents/* /mnt/Stuff/Documents
rmdir ~/Documents
ln -sd /mnt/Stuff/Documents ~/Documents

Hope this helps.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.