How to link different data storages with identical path?

Discussion in 'macOS' started by Girasole, Jul 18, 2011.

  1. Girasole macrumors newbie

    Joined:
    Jul 18, 2011
    #1
    Hello everyone,

    I am a Mac newcomer with maybe a trivial problem.

    I have two separate data storages but with identical data on both. One is a NAS (Network Attached Storage) *and one is a simple USB-drive.

    I would like to connect either one or the other storage into my Mac OS X, but i would like to create an identical link (path) in my Mac OS X to each of these storages, so that it cannot be recognized from the filepath by any program whether a file is stored on the NAS or on the USB.

    Do you understand what I mean?

    Under Windows I can achieve this by assigning a drive letter. But how to get it work under Mac OS X?

    Thanks and regards,
    Girasole
     
  2. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
    #2
    I'm not sure that is possible without a script to recreate the symlinks/aliases each time you exchange the drives since to the system they are not and can not be the same one. Well an alias might work for /Volumes/DRIVE/ but I'm pretty sure a symlink would map to the drive location instead of the Volumes instance. Have you tried making an alias with the /Volumes path?
     
  3. Girasole thread starter macrumors newbie

    Joined:
    Jul 18, 2011
    #3
    Hi Hansr,

    Thank you for your reply!

    How can I create an alias?

    What I have tried is to create a symbolic link with the following command in the terminal: ls -s Volumes/FREECOM/music ~/MyMusic

    But this is not working, because the files are still referring to Volumes/FREECOM/music.

    Any more ideas? I would really appreciate every advice!
     
  4. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
  5. Girasole thread starter macrumors newbie

    Joined:
    Jul 18, 2011
    #5
    ...no, they appear like this:

    1) NAS -> Volumes/music
    2) USB -> Volumes/FREECOM/music
     
  6. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #6
    What you are trying to do is not necessarily a wise thing. You want /volumes/music (usb) to show up in the same place as /volumes/freecon/music (nas)? This would mean that anything you did to one folder would happen to the other folder. Unix isn't really designed to do this. It is better to sync two folders so that changes made to one folder show up on the other one and vice versa. As for having the two folders "look like" they are in one place, how about this... (in terminal where myhomefolder is your user folder in OS X)

    Code:
    cd /users/myhomefolder
    md musiclinks
    cd musiclinks
    ln -s /volumes/music music1
    ln -s /volumes/freecon/music music2
    Now it "looks like" both folders are underneath a common folder called musiclinks

    Would this work for what you are trying to do?
     
  7. Girasole thread starter macrumors newbie

    Joined:
    Jul 18, 2011
    #7
    Hi r0k,

    I have already tried the symbolic link, but the files are still referring to the original path.

    So I'll explain a little bit about why I need this solution.

    1) On my MacBook Pro I organize a mediathek in iTunes, but all the mediafiles are stored on my NAS at home.
    2) On top of that, I have a complete backup of all these mediafiles on a separate USB-drive.

    Now, when I'm not at home and my NAS is not available, I really would like to just connect my USB-drive to my MacBook Pro and all the mediafiles are available again under the same path!
    With this little option I could still use the same one iTunes mediathek including all playlists, ratings, etc.! :)

    I would like to avoid maintaining 2 mediatheks...
     
  8. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
    #8
    How about this:

    Prefs file to indicated what was the most recent volume used:
    ~/.currVolumeCfg

    Shell script that checks to see which volume is available and creates a symlink in your homefolder to accommodate that volume and updates cfg accordingly. If neither exists, remove symlink. If same volume as in cfg exit without doing anything.
    /usr/local/bin/somescript.sh

    Then just put up a launchdaemon to run every 1,5 or 10 minutes or something accordingly and run the script.
     
  9. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
    #9
    Heck you can skip the cfg and just check the explicit path of the symlink, easier.

    And you could even have the script check the location or the connected SSID of the router etc to determine which to use.
     
  10. Jolly Jimmy macrumors 65816

    Jolly Jimmy

    Joined:
    Dec 13, 2007
    #10
    Forgive me if I'm missing something, but if the drive contents are identical, why don't you just give them both the same name?
     

Share This Page