How to include spaces in mount points for automount


On macOS I am attempting to set up an automount for a mount point with spaces.

/etc/auto_master contains:

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

and /etc/auto_afp contains:

'/mnt/mount point'    -fstype=afp    'afp://username:passwd@hostname/share%20name`

When I execute: sudo automount -vc, I get the error noted:

automount: dir '/mnt/mount point' must start with '/'
automount: /net updated
automount: /home updated
automount: /Network/Servers updated
automount: no unmounts

It has also failed if I use %20 without quoting (in that case it includes %20 in the mount point name).

How does one properly add spaces in a mount point?

Best Answer

You can escape with a backslash '\' character.

/mnt/mount\ point -fstype=afp 'afp://username:passwd@hostname/share_name'

How about "/mnt/mount point" or /mnt/"mount point"?

Another option is to use a name without a space.

Further research led me to this page about mounting folders another way.

The key here is that in Posix systems, the mount table is space delimited. So if your path includes spaces, they have to be escaped. Author of that page thinks \040 may be the escape character in OSX. If so, the syntax would be /mnt/mount\040point. He also noted that the solution was only tested in Leopard. Also, Craig Watson was pointing you here as well in the comments above.