Home > Computing, Lion, Mac, OS X, Software > Redirecting folders in OS X to a network drive

Redirecting folders in OS X to a network drive

I’ve recently managed to get OS X 10.7.1 running on my Core i7 box. My setup at home is such that I have a Dell Dimension E521 AMD x2 box stuffed with a couple of 1TB drives in a mirrored RAID-1 array acting as a file server amongst other things.

I wanted to be able to redirect folders such as Music and Documents in the /users/neil folder on my Mac to point to those on my server.

Having added a connection to my server via the Finder by using Go – Connect to Server… and adding it – in my case, it’s a Windows 2008 R2 box, so uses SMB for file sharing. Having put in smb://dellserv/storage (storage being the name of the share) and authenticating with my username and password, I was good to go.

For good measure, I also went to System Preferences – Users, then selected my username and added the share under Login Items to ensure that it is mounted when my Core i7 box boots up.

The next step was to actually create the symbolic links – these allow us to set up the redirect and are a very useful feature in any Unix/Linux/BSD-based system (OS X is based on BSD). I’ve worked with them previously when using Macs in the past plus when dabbling with Linux.

The aim is to redirect Documents, Music, Pictures, Movies and Downloads to their relevant locations on the Dell box.

First, we need to bring up a Terminal window (from Applications – Utilities).

Using Music as our first example, we need to first delete the existing Music directory on the Mac. As the folder is treated as a system folder, we need elevated permissions, hence the use of the sudo command:

corei7:volumes neil$ sudo rm -rf /users/neil/Music
Password: (enter your password here)

Next, we need to set up the symbolic link, which creates the redirect to the Dell box. Remember that the SMB (Windows) share is mounted on the Mac in /volumes/sharename. The command is as follows:

corei7:volumes neil$ ln -s /Volumes/storage/Neil/Music/ /users/neil/Music

ln -s creates the symbolic link (i.e. the redirect), /Volumes/storage indicates the Windows share plus the path to the music folder on the Dell server and /users/Neil/Music is the path to the Music folder on the Mac.

Repeat for your other folders – I’ve pasted the output for the others that I used below:

corei7:volumes neil$ sudo rm -rf /users/neil/Downloads/
corei7:volumes neil$ ln -s /Volumes/storage/Neil/Downloads/ /users/neil/Downloads
corei7:volumes neil$ sudo rm -rf /users/neil/Pictures/
corei7:volumes neil$ ln -s /Volumes/storage/Neil/Photos/ /users/neil/Pictures
corei7:volumes neil$ sudo rm -rf /users/neil/Movies
corei7:volumes neil$ ln -s /Volumes/storage/Neil/Videos/ /users/neil/Movies
corei7:volumes neil$ sudo rm -rf /users/neil/Documents
corei7:volumes neil$ ln -s /Volumes/storage/Neil/Documents/ /users/neil/Documents

Don’t forget to change the first part in the ln -s commands to point to the correct location on your network drive! The above is an example using the network paths on my network.

Job done – hopefully if you go into your home folder in Finder and click on Music or Documents etc. then you’ll be redirected to the relevant location on your network.

Hope you’ll find this of use! Comments/feedback appreciated!

About these ads
Categories: Computing, Lion, Mac, OS X, Software
  1. Mihnea
    April 6, 2014 at 6:07 pm

    Just did that on OSX Mavericks and a Synology NAS and it worked. Now let’s wait and see how the applications behave with this symlink.
    Thanks a lot for sharing!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: