2

I have 2 SMB servers that I connect to on a daily basis. One is my development server and the other is my production server. Both of them are a little different in the folder structure.

When they are mounted, they take the names of the folder you are mounting. Both servers are mounted on the same folder name so its really hard to tell the difference.

Is it possible to change the name of a mounted SMB server? I would like to just have "Development" and "Live".

4
  • How do you mount your SMB-shares?
    – klanomath
    Dec 3, 2014 at 15:22
  • I usually use finder and click GO > Connect to server > smb://xx.xx.xx.xxx. I am all for doing it another way if its possible to give an alias.
    – SBB
    Dec 3, 2014 at 15:23
  • then you have to adjust it on the server side (Windows? Linux? Apple?)
    – klanomath
    Dec 3, 2014 at 15:25
  • It's windows but I figured renaming should be an option or creating a shortcut to it somehow and have that with a custom name.
    – SBB
    Dec 3, 2014 at 15:26

2 Answers 2

2
  1. auto_fs method

The two shares will be mounted automatically.

Please create a Share folder and two folders Development and Live inside of that in your User folder and change your auto_master with sudo nano /etc/auto_master to

/etc/auto_master

#
# Automounter master map
#
+auto_master                        # Use directory service
/-                                  auto_smb    -nosuid
/net                                -hosts      -nobrowse,hidefromfinder,nosuid
/home                               auto_home   -nobrowse,hidefromfinder
/Network/Servers                    -fstab
/-                                  -static

and create a file with sudo touch /etc/auto_smb and add with sudo nano /etc/auto_smb the content

/etc/auto_smb

/Users/username/Share/Development -fstype=smbfs,noowners,soft ://user:password@dev-server_ip/Shared_Folder
/Users/username/Share/Live -fstype=smbfs,noowners,soft ://user:password@prod-server_ip/Shared_Folder 

for AD-members

/Users/username/Share/Development -fstype=smbfs,noowners,soft ://DOMAIN\;user:password@dev-server_ip/Shared_Folder
/Users/username/Share/Live -fstype=smbfs,noowners,soft ://DOMAIN\;user:password@prod-server_ip/Shared_Folder  

Both files ("auto_master" & "auto_smb") need a trailing empty line

change the file root only readable:

sudo chown 600 /etc/auto_smb

enter sudo automount -vc in Terminal with the output:

$ sudo automount -vc
automount: /Users/username/Share/Development updated
automount: /Users/username/Share/Live updated
automount: /net updated
automount: /home updated
automount: no unmounts

Please regard the output: /Users/username/Share/Development or Live updated

(I've tested this with Mac OS X 10.10.1 (as client) & Windows Server 2012 R (Active Directory) in a VirtualLab. It worked without any problems and survived any restart. The following workarounds weren't necessary for me.)

If the shares aren't mounted with correct access rights (e.g. root only) you may have to unmount it with sudo umount /Users/.../sharesand remount it with `cd /User/.../shares.

An automatic approach with launchd is the following solution:

Create a script:

while ! mount | grep "map auto_smb on /Users/user/Share  
do  
        sleep 2  
done  

if ! mount | grep "mount .* mounted by user"  
then  
        sudo umount /Users/user/Share/Development
        sudo umount /Users/user/Share/Live
        sudo -u user cd /Users/user/Share/Development  
        sudo -u user cd /Users/user/Share/Live
fi  

(i don't know if line 1 in the script is correct)

and save it somewhere e.g. /Users/user/bin/remount.sh.

To call the script as a LaunchDaemon, you have to create a plist in /Library/LaunchDaemons similar to this:

<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"     "http://www.apple.com/DTDs/PropertyList-1.0.dtd">  
<plist version="1.0">  
<dict>  
          <key>Label</key>  
          <string>com.organization.remount</string>  
          <key>ProgramArguments</key>  
          <array>  
                    <string>/Users/user/bin/remount.sh</string>  
          </array>  
          <key>RunAtLoad</key>  
          <true/>  
</dict>  
</plist>  

The string com.organization.remount is also the name you will have to give the file, with the extension plist: "com.organization.remount.plist".

The string /Users/user/bin/remount.sh is the path to where you saved your script.

2. Windows Server2008r2 command line-method (if you have admin rights and access to the servers)

really quick and dirty: net share <sharename=drive:path>

Example:
net share Live=C:\Data (on the production server)
net share Development=C:\Data (on the development server)

8
  • I did this and both show up in the users folder with their respective names and go to the correct place. Is there a way to create a shortcut now for these to be on the desktop?
    – SBB
    Dec 3, 2014 at 16:20
  • sure. just make 2 aliases
    – klanomath
    Dec 3, 2014 at 16:22
  • Hmm, after restarting the folders still show up but when I click them, they don't connect at all.
    – SBB
    Dec 3, 2014 at 16:41
  • hmm i've updated the auto_master auto_smb -> auto_smb -nosuid. run "sudo automount -vc" again afterwards
    – klanomath
    Dec 3, 2014 at 16:50
  • Is it required to use the user:pass in the file? I didn't use it on mine as it wasn't required when I did it through "Connect to Server".
    – SBB
    Dec 3, 2014 at 16:53
1

Here's one suggestion: https://superuser.com/questions/775539/custom-names-for-smb-shares-on-osx

I've used a similar method to mount volumes using sshfs to particular mount points for iTunes and calibre and the like.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .