DartFS mount on Mac with Linux-style file paths
The default mount points for network shares on MacOS, when created by Finder, are below /Volumes/sharename. This presents an obstacle to developing code on a Mac which needs to reference any absolute file paths (non-relative), and then run that code on the Linux cluster, where the network shares are mounted at /dartfs (or /dartfs-hpc for some older shares)
MacOS can mount network shares in different locations, but there is problem with making them appear in the root directory (/dartfs/rc/….). In MacOS 10.15 (Catalina) and later, the root directory is part of the readonly root volume, and you can’t create folders there. However, MacOS has a mechanism to create symbolic links
in the root directory, which can be used to achieve the same effect. (Reference:
creating-root-level-directories-and-symbolic-links-on-macos-catalina/, or man synthetic.conf
in the Mac Terminal)
Create (or edit, if it exists) the file /etc/synthetic.conf
. You need to do this as root, e.g. in Terminal: sudo vi /etc/synthetic.conf
or sudo touch /etc/synthetic.conf; sudo open -a TextEdit /etc/synthetic.conf
Apple’s TextEdit doesn’t make it easy to create a new plain text file, hence the touch command to create the file first. Any other programming editor should work too.
Add the following lines. You can use the # syntax to add whatever comments you want. Replace USERNAME with your Mac user name. Note that you need a TAB between the columns. It will look something like this, but the tabs will not be obvious (vs. spaces)
# SMB mount points to provide same paths as on Linux/NFS
dartfs /Users/USERNAME/dartfs
dartfs-hpc /Users/USERNAME/dartfs-hpc
Create the empty folders for the real mount points, in your Mac home directory. Use mkdir
in Terminal, or Finder’s File:New Folder. E.g., in Terminal:
mkdir -p ~/dartfs/rc ~/dartfs-hpc/rc
Reboot. This is needed to get new folder links, but you only need to do it once.
Your root directory will now have two symlinks. In Finder they appear as aliases. In Terminal, ls -l
will show
lrwxr-xr-x 1 root wheel 21 Oct 19 14:49 dartfs -> /Users/USERNAME/dartfs
lrwxr-xr-x 1 root wheel 25 Oct 19 14:49 dartfs-hpc -> /Users/USERNAME/dartfs-hpc
Next, we mount the top levels of DartFS into your Mac home directory (not the default Finder mount into /Volumes). The Terminal commands are as follows. Replace the NETID in the authentication part with your own Dartmouth NetID. You may be prompted for your NetID password.
mount -t smbfs "//KIEWIT;NETID@dartfs.dartmouth.edu/rc" /dartfs/rc && open $HOME/dartfs
mount -t smbfs "//KIEWIT;NETID@dartfs-hpc.dartmouth.edu/rc" /dartfs-hpc/rc && open $HOME/dartfs-hpc
Once completed, any references in code to, for example, /dartfs/rc/lab/M/Mylabshare will go to the same file as that references on Linux. This applies to code in any language (e.g. Python, R, Stata).
The attached mount-dartfs.command
clickable script assumes the /etc/synthetic.conf step has been done, and will perform the mounts and open two Finder windows for */dartfs/rc *and /dartfs-hpc/rc. If your Mac username is NOT your NetID, you should edit the file $HOME/.zshrc
and add the line
export NETID=netid
replacing netid with your NetID. This tells the mount-dartfs
script which NetID to use. You only need to do this once.
mount-dartfs
tests for cached credentials, and if not found, it launches the *Ticket Viewer *app. This Apple-supplied tool is not well documented. A good description can be found at
Kerberos on MacOS An alternative is to run kinit $NETID@KIEWIT.DARTMOUTH.EDU
in Terminal. As an unsigned script, you will need to control-click the first time and tell MacOS it is permitted to run this script from an unidentified developer.