Mount Windows shares on proper paths in OS X

Dec 28, '07 07:30:00AM

Contributed by: brianray

Often from my friends in Window's land, I get the paths like this:

\SERVERsharepathtofile.txt
When converted to a file URL on the Mac, this will look something like:
file://SERVER/share/path/to/file.txt
Unfortunately, when I mount the volume on OS X using the normal method, the share shows up under /Volumes with a naming scheme not compatible with the file URL above. My workaround involves making a directory and mounting:
  1. Mount the server the normal way (Command-K in Finder).
  2. Check Remember Password option when authenticating.
  3. Unmount the drive in the Finder -- very important!
  4. Make a directory in Terminal with the sever and share name: mkdir -p /SERVER/share.
  5. Mount the server with the command mount_smbfs //`whoami`@SERVER/share/ /SERVER/share. NOTE: if your short Unix username does not match your Windows server login, make it match. If it requires a domain, things like NNN\;bray are perfectly acceptable.
Once this is done, you should test it out and click on the file URL. This should bring up the program in the same application as if you had double-clicked on the file as assigned by Launch Services.

To take it a bit further, you can mount the drive from startup.

  1. Create directory mkdir -p /Library/StartupItems/AutoMount
  2. Create two files, AutoMount and StartupParameters.plist in that directory. In the AutoMount file put the following:
    #!/bin/sh
    . /etc/rc.common
    # The start subroutine
    StartService() {
       mount_smbfs //NDNW:bray@SERVER/share/
    }
    
    # The stop subroutine
    StopService() {
      unmount SERVER/share
    }
    
    # The restart subroutine
    RestartService() {
     StopService
     StartService
    }
    
    RunService "$1"
    In the StartupParameters.plist file goes this:
    {
      Description     = "Mounts";
      Provides        = ("Mounts");
      OrderPreference = "Late";
      Messages =
      {
        start = "Starting Software Update service";
        stop  = "Stopping Software Update service";
      };
    }
You should restart, and the drive should mount automatically. If you do not see it, look in your Console for notes. I tested the method on 10.4, but it should work on 10.5, as well. If you want to be technical, you may find more details on this process in this developer's note on Apple's site.

[robg adds: I have modified the formatting and some of the content from the original blog post provided by the hint's author.]

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20071222101259706