Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Linking your documents folder (and others) in Ubuntu to a Data Partition?

  • 03-01-2012 05:38PM
    #1
    Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭


    Just wondering here if there is a way to do this? I remember trying to do it before but it wasn't as straight forward as changing the location of a folder in windows. At least I never found a proper answer apart from just putting a short cut to the folder in the other partition.

    Essentially what I would like to do is to use my data partition for both windows and Linux without having to manually move everything to the partition. I don't like saving data with the OS.

    Anyone know how this can be done?


«1

Comments

  • Moderators, Arts Moderators Posts: 36,031 Mod ✭✭✭✭pickarooney


    The partition will probably have to be in FAT32 for starters, or possibly NTFS. I'm not sure what you mean with the next bit - where is the data you want to share currently in relation to / and /home ?


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    The partition will probably have to be in FAT32 for starters, or possibly NTFS. I'm not sure what you mean with the next bit - where is the data you want to share currently in relation to / and /home ?

    Well before I had an Ubuntu partition I had a partition for Windows OS and a partition to store all my data. I then relocated all my windows folders, i.e. My documents, my videos etc. to this partition. This is done by right clicking the folder and going to the location tab and writing in, for example D:\MyDocuments. Now when ever I save anything to my documents folder in windows it is saved in that partition. Its very handy and keeps all my data away from the OS partition, but the folders are still linked to the OS.
    OSI wrote: »
    You could create the folders on your data partition and use symbolic links to link the folders in your home directory to them.

    ie

    mv /home/username/Documents /mnt/Data/Documents
    ln -s /mnt/Data/Documents /home/username/Documents
    

    Windows 7 actually provides for something similar to sym links now too, so may be worth a look.

    I'm sorry I don't really understand what sym links are?


  • Registered Users, Registered Users 2 Posts: 14,081 ✭✭✭✭Johnboy1951


    Do you have the option to drag and drop the directory to another location, and then choose from options ...... one of which is 'link here'?

    It is what I use .... but don't use ubuntu .. so it may be different


  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    symlinks or "symbolic links" are probably what you're looking for. In ubuntu lets say you have your NTFS data partition mounted at /home/shizz/data/ and you want to relocate /home/shizz/Documents to /home/shizz/data/Documents what you would do is this:

    Delete the /home/shizz/Documents folder (having backed up anything that's in it that you want to keep)
    create /home/shizz/data/Documents folder
    symlink /home/shizz/data/Documents to /home/shizz/Documents

    That way when you access /home/shizz/Documents, you're really accessing /home/shizz/data/Documents.

    The command you want to create the simlink is:

    ln -s <src> <destination>

    e.g. ln -s /home/shizz/data/Documents /home/shizz/Documents

    Symlinks are one of the things I love about linux. They just add so much flexibility.


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    Khannie wrote: »
    symlinks or "symbolic links" are probably what you're looking for. In ubuntu lets say you have your NTFS data partition mounted at /home/shizz/data/ and you want to relocate /home/shizz/Documents to /home/shizz/data/Documents what you would do is this:

    Delete the /home/shizz/Documents folder (having backed up anything that's in it that you want to keep)
    create /home/shizz/data/Documents folder
    symlink /home/shizz/data/Documents to /home/shizz/Documents

    That way when you access /home/shizz/Documents, you're really accessing /home/shizz/data/Documents.

    The command you want to create the simlink is:

    ln -s <src> <destination>

    e.g. ln -s /home/shizz/data/Documents /home/shizz/Documents

    Symlinks are one of the things I love about linux. They just add so much flexibility.

    Nice. Thanks man. This seems like what I am looking for, but the way you have written /home/shizz/data/documents looks like to me that data is a folder within home? Maybe I'm just not familiar with directories in linux.

    Also would I put in the command after I have deleted the original home folder? Does this command now make the folder in the data partition my home folder or does it create a new home folder and just link it to there?

    Just trying to get my head around the code.

    Thanks again.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    shizz wrote: »
    Nice. Thanks man. This seems like what I am looking for, but the way you have written /home/shizz/data/documents looks like to me that data is a folder within home? Maybe I'm just not familiar with directories in linux.

    Linux treats directories differently to windows. You need a slight mind shift, but only very slight. You mount partitions at a particular directory instead of their own drive. So lets say I have a partition on my hard drive that has all my movies in it and another partition that has all my music, well I would maybe mount them at:

    /home/khannie/music
    and
    /home/khannie/movies

    Then when I go into that directory, I can see the contents of the partition inside that directory. In Linux (or unix in general) you can mount all sorts of things this way. Remote file systems for example, or USB drives. In your case, I was saying you might mount your data partition at /home/shizz/data but actually you can put it wherever you like.

    To mount it you use the mount command, e.g.:

    mount <partition> <mount point>

    an example might be:

    mount /dev/sda1 /home/shizz/data

    (your data partition is listed as a device under /dev and should be /dev/sd<something> like /dev/sda1 or /dev/sdb1 or similar.
    shizz wrote: »
    Also would I put in the command after I have deleted the original home folder?

    In a terminal. This is similar to the command prompt in windows (or the start->run box). In ubuntu it's under applications->accessories->terminal. The more time you spend with linux, the more you'll use the terminal. Again it's a bit of a mindset shift. Try not to be freaked out by the terminal. :)

    edit: for whatever reason I read that as "where would I". Also, you don't delete the home folder. VERY IMPORTANT. Only the Documents subdirectory.
    shizz wrote: »
    Does this command now make the folder in the data partition my home folder or does it create a new home folder and just link it to there?

    It creates a link, which looks and behaves like a folder. If you remove the link though, it does not remove the folder that it links to.

    Hope that helps. Getting ready for your raspberry pi? ;)


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    Khannie wrote: »
    Linux treats directories differently to windows. You need a slight mind shift, but only very slight. You mount partitions at a particular directory instead of their own drive. So lets say I have a partition on my hard drive that has all my movies in it and another partition that has all my music, well I would maybe mount them at:

    /home/khannie/music
    and
    /home/khannie/movies

    Then when I go into that directory, I can see the contents of the partition inside that directory. In Linux (or unix in general) you can mount all sorts of things this way. Remote file systems for example, or USB drives. In your case, I was saying you might mount your data partition at /home/shizz/data but actually you can put it wherever you like.

    To mount it you use the mount command, e.g.:

    mount <partition> <mount point>

    an example might be:

    mount /dev/sda1 /home/shizz/data

    (your data partition is listed as a device under /dev and should be /dev/sd<something> like /dev/sda1 or /dev/sdb1 or similar.



    In a terminal. This is similar to the command prompt in windows (or the start->run box). In ubuntu it's under applications->accessories->terminal. The more time you spend with linux, the more you'll use the terminal. Again it's a bit of a mindset shift. Try not to be freaked out by the terminal. :)

    edit: for whatever reason I read that as "where would I". Also, you don't delete the home folder. VERY IMPORTANT. Only the Documents subdirectory.



    It creates a link, which looks and behaves like a folder. If you remove the link though, it does not remove the folder that it links to.

    Hope that helps. Getting ready for your raspberry pi? ;)

    Thanks for putting all the effort into the post really appreciate it. Cleared a lot up.

    Just two more things, If I mount this drive is it still readable by my windows partition? I presume so but just checking.

    Also, the command you gave me to link the folder is just one line where as OSI gave me a command with two lines. Is the first command just to mount the drive? It looks that way to me.

    Thanks again.


  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    I'm going to teach the man to fish with this one....

    in a terminal, run:

    man mv

    To quit out of it, hit q.

    Man is short for "manual" and really is your friend.


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    Khannie wrote: »
    I'm going to teach the man to fish with this one....

    in a terminal, run:

    man mv

    To quit out of it, hit q.

    Man is short for "manual" and really is your friend.
    Thanks man. Ill write back here when I get it working. Might be a while though. thanks again.


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    Quick question about mounting. When I log into Ubuntu my Partition is there and available to use. Ive named the Partition "DATA" so It turns up as that. So do I need to mount it? is it not already?

    Also if I was to mount it how do I know which sd it is?


  • Advertisement
  • Moderators, Arts Moderators Posts: 36,031 Mod ✭✭✭✭pickarooney


    I get the feeling everything is being overthought here...

    My understanding is that currently you have (at least) three partitions:
    1. Windows OS partition
    2. Linux OS partition
    3. Data partition common to both

    I'm assuming 3. is in NTFS and that your Ubuntu installation can at least read from the drive, possibly writing to it as well.

    So when you're in Windows 3. is mounted automatically as, say (D:) and when you're in Ubuntu the same drive is mounted as something like /media/windows with the disk label DATA. Assuming you can write to the drive you don't really need to do any of the above, just make sure that when you save any data files in Ubuntu that you save them in a folder on this partition. When using a GUI Save File dialog box the disk should be visible as "DATA" or something like "500GB Drive (/media/windows)".


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    I get the feeling everything is being overthought here...

    My understanding is that currently you have (at least) three partitions:
    1. Windows OS partition
    2. Linux OS partition
    3. Data partition common to both

    I'm assuming 3. is in NTFS and that your Ubuntu installation can at least read from the drive, possibly writing to it as well.

    So when you're in Windows 3. is mounted automatically as, say (D:) and when you're in Ubuntu the same drive is mounted as something like /media/windows with the disk label DATA. Assuming you can write to the drive you don't really need to do any of the above, just make sure that when you save any data files in Ubuntu that you save them in a folder on this partition. When using a GUI Save File dialog box the disk should be visible as "DATA" or something like "500GB Drive (/media/windows)".

    Yeah this is exactly the situation and what I have been doing, but ideally I would like to link the home folders to this data partition so that if anything is automatically saved to there it goes to the Data without me having to maually do it. For example downloads.


  • Moderators, Arts Moderators Posts: 36,031 Mod ✭✭✭✭pickarooney


    Just set the default Downloads folder of your browser to be a folder on the data partition? Same with Openoffice and any other program you regularly save files from.
    You're not really 'locked in' to a My Documents folder the way you are in Windows by default.


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    Just set the default Downloads folder of your browser to be a folder on the data partition? Same with Openoffice and any other program you regularly save files from.
    You're not really 'locked in' to a My Documents folder the way you are in Windows by default.

    Yes but then I have directories that come as standard set out for your documents, music, video etc. What I would like is for those to link straight to the corresponding folders in my data partition that has all my music, videos etc

    I don't think I was locked to anything in Windows though? It was far easier to accomplish this in windows.

    Anyway Im sure sym links is what Im looking for.


  • Registered Users, Registered Users 2 Posts: 14,081 ✭✭✭✭Johnboy1951


    I don't see the difficulty ....

    using a file manager (preferably Split View, or if not available then two instances) you can drag any Folder from /home to another partition and select 'move' here.

    when that is finished you can drag and drop the folder back to /home and select to 'link' here. Job done! ... as I understand your requirement.


  • Moderators, Arts Moderators Posts: 36,031 Mod ✭✭✭✭pickarooney


    shizz wrote: »
    Yes but then I have directories that come as standard set out for your documents, music, video etc.

    I don't really understand what you mean here or what program you're using that tries to put these files in folders you don't want them to go to. Can you give a couple of examples?


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    I don't really understand what you mean here or what program you're using that tries to put these files in folders you don't want them to go to. Can you give a couple of examples?

    Well for example Im on Xubuntu. Now if you click on the folder icon on the dock it brings up a list of folders like Desktop, Documents, music, Videos etc. These folders come with the install ie I didnt make them. and then anything saved into them are saved on the operating systems partition. What I'd like to do is to be able to click on that Videos folder for example and be taken straight to where all my videos are on the data partition.

    It seems like the cleanest way of storing all my files, and brings down the amount of clicks id have to do.


  • Moderators, Arts Moderators Posts: 36,031 Mod ✭✭✭✭pickarooney


    Any chance of a screenshot? I use xubuntu but with cairo dock so I don't have the same default shortcuts. I'm kind of starting to understand what you're after now, I just use the OS in a different way.


  • Registered Users, Registered Users 2 Posts: 14,081 ✭✭✭✭Johnboy1951


    shizz wrote: »
    Well for example Im on Xubuntu. Now if you click on the folder icon on the dock it brings up a list of folders like Desktop, Documents, music, Videos etc. These folders come with the install ie I didnt make them. and then anything saved into them are saved on the operating systems partition. What I'd like to do is to be able to click on that Videos folder for example and be taken straight to where all my videos are on the data partition.

    It seems like the cleanest way of storing all my files, and brings down the amount of clicks id have to do.

    Then what I have described will do that, while still leaving a link to the new location under /home/<user-name>, so that you can access them through a file manager just as easily.

    As I said, I don't use Ubuntu/Gnome, but I doubt very much if it is very different to all other Linux flavours in this respect.


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    Any chance of a screenshot? I use xubuntu but with cairo dock so I don't have the same default shortcuts. I'm kind of starting to understand what you're after now, I just use the OS in a different way.

    screenshotmenuu.png

    Uploaded with ImageShack.us

    As you can see here I've clicked the folder icon on the dock and brought up the default folders. If I was to click into any of these I would like it to go straight to the relative folder that I choose in my Data partition.

    screenshotmenu2.png

    Uploaded with ImageShack.us

    And as you can see on this one, I am in the file browser and the default folders are present on the left, with the folders from my data partition on show. You can see the Music folder in my data partition there. Ideally I would like that folder to open when I click the default music folder on the left.

    Then what I have described will do that, while still leaving a link to the new location under /home/<user-name>, so that you can access them through a file manager just as easily.

    As I said, I don't use Ubuntu/Gnome, but I doubt very much if it is very different to all other Linux flavours in this respect.

    Yeah I tried what you said about dragging and dropping. If I try to drag the folder on the left over on to the folder I wish to link it to, it does nothing. Just slides back to its original position.

    I hope this clears it up but I am going to try the sym links thing now to see if it works.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    Ok so ive tried the ln -s command in so may different ways trying to get the directory right, but it hasn't worked.

    It was reccommended to use ln -s /home/colin/DATA/Documents /home/colin/Documents

    Its created some link in the documents folder but nothing has happened. So I thought I got the directory wrong as DATA is in media under file systems not home. But this didn't work either. Or do I have to undo what I did before?


  • Registered Users, Registered Users 2 Posts: 14,081 ✭✭✭✭Johnboy1951


    Yeah I tried what you said about dragging and dropping. If I try to drag the folder on the left over on to the folder I wish to link it to, it does nothing. Just slides back to its original position.

    I hope this clears it up but I am going to try the sym links thing now to see if it works.

    If you open two instances of the file manager (or split view if available), with one pane showing /home/<user-name> and the other pane showing the destination location.

    Presumably the destination is a partition mounted maybe in /media or other .... so the second location might be
    /media/DATA .... depending on mount point.

    You then drag the folder from the main pane (not the left) over to the other, and select to move. You can drag it back and select to link.

    BTW ...... you can delete any of those folders in /home/<user-name> if you wish.
    For instance delete the Music folder (if there is nothing in it you need).
    You can then create a folder called Music on any other partition, and link that back by dragging and dropping it as described.
    There is nothing particularly sacred about the folders that are there by default. ;)

    regards.


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    If you open two instances of the file manager (or split view if available), with one pane showing /home/<user-name> and the other pane showing the destination location.

    Presumably the destination is a partition mounted maybe in /media or other .... so the second location might be
    /media/DATA .... depending on mount point.

    You then drag the folder from the main pane (not the left) over to the other, and select to move. You can drag it back and select to link.

    BTW ...... you can delete any of those folders in /home/<user-name> if you wish.
    For instance delete the Music folder (if there is nothing in it you need).
    You can then create a folder called Music on any other partition, and link that back by dragging and dropping it as described.
    There is nothing particularly sacred about the folders that are there by default. ;)

    regards.

    Ahhh thanks man. I think youv'e explained why my ln -s wasn't working. I never deleted the previous folder.

    Yeah I guess that's just the windows head on me thinking they are. IIRC you can't replace the default folders on windows, Or if you do they loose the icons on them. I like icons :) haha

    Thanks again man I'll give it a try soon.


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    Ok so simply deleting the documents folder and then throwing my data partition documents folder worked but it doesn't show up on the list of folders when the folder icon on the dock is clicked


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    Ok so I was having problems with my Windows partition so had to Reinstall everything today and I decided to go for Ubuntu 11.10. The sym links worked and everything is as I want it to be.

    I really learnt a lot about the terminal with this.

    Thanks Everyone :) Delighted.


  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    Ok so after more or less a day with the sym links thing I have noticed that when I turn on the computer the folders aren't automatically linked. Like if I click on the folder it says such a folder doesn't exist. But if I then go to the Data partition and enter the folder I'm trying to enter, a few seconds later they get linked up again. Is there anyway around this?


  • Moderators, Technology & Internet Moderators Posts: 1,336 Mod ✭✭✭✭croo


    I would guess what's happening is, the "Data" partition is not being mounted by default. When you click on it via Nautilus (i.e. the file browser), it automatically mounts it for you and then the links appear to work.

    What partitions are loaded automatically when the system starts up is defined in a file /etc/fstab (fstab= File System Table).

    There might be some GUI tools to help define the fstab file but I just edit it manually. Usually you can just copy a previous entry, the important pieces of information are what is to be mounted & where to mount it. "What" is usually defined in ubuntu by the UUID of the disk partition which I find using gparted - select a partition and right click to select information. In other distros the df -h command displays uuid info but not in ubuntu (or if it does I don't know the command switch to use).


  • Registered Users, Registered Users 2 Posts: 14,081 ✭✭✭✭Johnboy1951


    blkid

    should show the UUID as well as other info.


  • Closed Accounts Posts: 3,654 ✭✭✭shadowninty


    fstab needs to be edited to mount the partition at boot
    terminal wrote:
    sudo gedit /etc/fstab
    Be careful doing this, don't mess up your / partition. If you do, I know you can edit fstab from the File Manager in Parted Magic.

    I'll throw up the command I put in fstab when I get to my laptop.

    Ok, here it is, obviously change it the the relevant partition (/dev/sd[hard drive][partition]), and the desired mount point.
    /dev/sda7 /media/.data ext4 dev,suid,exec 0 2


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,506 ✭✭✭shizz


    fstab needs to be edited to mount the partition at boot


    Be careful doing this, don't mess up your / partition. If you do, I know you can edit fstab from the File Manager in Parted Magic.

    I'll throw up the command I put in fstab when I get to my laptop.

    Ok, here it is, obviously change it the the relevant partition (/dev/sd[hard drive][partition]), and the desired mount point.

    /dev/sda7 /media/.data ext4 dev,suid,exec 0 2

    I was wondering if you could explain this command a bit more. My data partition is NTFS not ext4. and what does the end part mean?

    Also is it as simple as just putting this command straight in nothing else?


Advertisement