Shallow Thoughts
Random stuff for the pixel monkey in all of us. With your host, Kevin Schmitt
 
« November 2008
SunMonTueWedThuFriSat
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
      
Today
 
 
 
 
 
Thursday May 10, 2007
 

Mac Tip: sharing specific locations to Windows machines

It's easy enough to turn on Mac OS X's built-in Samba server to share your Mac with Windows-based computers (System Preferences:Sharing:Services Tab:Windows Sharing), but the lack of configuration is a mite frustrating. However, you can assert some control by selectively sharing certain folders or drives on your system through the use of symbolic links (or symlinks). By default, once you pick an account that can be shared to Windows machines, Mac OS X will share the Home directory for that account when a Windows user logs in. Now, if you use your Documents folder to store all your files in, this approach is all you'll need. But if you have a separate development drive or a specific folder you want to share, the Home directory isn't going to cut it. Hence the use of symlinks, which are the Unix equivalent to the Classic Mac OS (and OS X, for that matter) alias feature. In a nutshell, though, symlinks are a little more "real" as far as the file system is concerned, appearing to whatever is reading it as the actual linked file, folder, or drive instead of a file type. So, in the case of sharing folders, here's what to do:

First, create a new folder in your Home directory called "Shares." That's where we're going to stash our symlinks. Next, fire up the Terminal (realizing that some of you may be Terminal-adverse, but this isn't one of the scarier operations that one can do in the Terminal). At the command prompt (which should open by default in your Home folder), type the following:

ln -s /path/to/shared/folder Shares/sharename

To break this down a bit, here's what's going on: ln -s is the command to create the symlink, /path/to/shared/folder is the Unix path to the folder you want to share, and Shares/sharename is what you want the share named as. Of course, replace the path to the shared folder with the one you actually want to share and the sharename with whatever you want, but that's the gist. And as a "hint-within-a-hint" sort of thing, you can easily determine the Unix path of any file, folder, or drive on your system by simply dragging it from the Finder into the Terminal window. So, using that method, you'd do something like this from the Terminal prompt:

ln -s <Drag in the target folder from the Finder> Shares/sharename

Again, replacing sharename with what you want the share to appear as in the Shares directory you just made. So, how would you mount this new share on a Windows box? Simple enough. Let's say that your short OS X user name is joeuser (as opposed to the long name, the one which appears in the OS X login screen, which is Joe User). Let's also say that the IP address of your machine is 1.2.3.4 (you can use the machine name, but I've found that Windows only reliably mounts IP addresses). You can find out your IP address pretty easily; Mac OS X will provide it in the instructions on the Sharing Preference pane once you enable a service. Lastly, let's assume the name of the symlink (which points to your target folder or directory) is MyShare. So, in Windows, you'd click the Start Menu, select Run, and in the Run box enter the following:

\\1.2.3.4\joeuser\Shares\MyShare

Now, I'm not 100% sure, but I think that if you're using Vista you can just enter that directly in the Search box and it will work. After entering your Mac username and password, you should be good to go. I've tried other methods (using the OS X computer name, going through the Network Neighborhood, and even third-party sharing utilities), and this is the only method that's proved consistently reliable for me. Of course, your mileage may vary depending on how permissions on other drives and folders are set, and I would naturally caution you that this isn't a terribly security-focused piece of advice in general, but for those in limited setups for whom these things aren't issues, a simple symlink or three can add enormous flexibility when sharing your Mac to Windows machines.

Comments:

Post a Comment:
  • HTML Syntax: Allowed