5

I've looked at a few of the entries in the "Similar Questions" field when starting this question, but they didn't help.

I need to mount a network drive to a mount point I have created in /Volumes/Synology/backup. I need it mounted at boot time - not at login. The NAS drive is a cifs filesystem on my Synology NAS. I understand from this Q&A that it's possible to mount a drive by creating an entry in /etc/fstab. I'm familiar with this on my Linux systems, and expected that some of the fstab parameters might be different in macOS.

I consulted man fstab, opened /etc/fstab using sudo vifs, and created the following entry:

//SynologyNAS-1/backups /Volumes/Synology/backup msdos rw 0 2

Note that the mount point ends in backup, and the NAS share name ends in backups; i.e. not an error.

In other words:
fs_spec = //SynologyNAS-1/backups
fs_file = /Volumes/Synology/backup
fs_vfstype = msdos (closest to cifs in man fstab)
fs_mntops = rw
fs_freq = 0
fs_passno = 2

The attempted mount was a disaster:

% sudo mount -a
mount_apfs: volume could not be mounted: Operation not permitted
mount: / failed with 77
mount_msdos: /SynologyNAS-1/backups: No such file or directory
mount: /Volumes/Synology/backup failed with 71

Does this even work in macOS? The other Q&A says, "Don't worry if it tells you it can't mount a volume." ha ha - seriously? I took that as a joke. Has Apple actually left a dysfunctional mount command in their distribution?

In any event: My actual question is, as stated in the title/subject:

How can I mount an NAS drive at a specified mount point & make it persistent?

3 Answers 3

1

I am by no means an expert, but here is what I did to mount my synology shares as persistent mount points on my Mac (in my case it is using NFS, so if you are using smb or afp it will be a little different - but a little googling might help there):

First, edit /etc/auto_master.

It should look something this:

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

Add a line at the end that looks like this:

/-          auto_nfs    -nosuid

Note how I did not include nobrowse as an option. I found that if I did that I could not browse the mounted shares via the Finder. But, again, since I am not an expert I don't know if this also has other ramifications. It just seems to be working for me.

Next, create a file in /etc called auto_nfs (again, this if for an NFS mount. SMB and AFP will be similar. Just create auto_smb or auto_afp files instead, and make sure that they are referenced in your auto_master file instead of auto_nfs).

This file should look something like this:

/System/Volumes/Data/show -fstype=nfs,noowners,nolockd,resvport,hard,bg,intr,rw,tcp,nfc,rsize=8192,wsize=8192 nfs://192.168.1.100:/volume1/show
/System/Volumes/Data/assets -fstype=nfs,noowners,nolockd,resvport,hard,bg,intr,rw,tcp,nfc,rsize=8192,wsize=8192 nfs://192.168.1.100:/volume1/assets

Obviously you should add as many lines as you have shares, and you will need to create the directories yourself using the sudo command (by 'directories' I mean the entries like /System/Volumes/Data/show and /System/Volumes/Data/assets)

Now the shares (/volume1/show and /volume1/assets) will auto mount to these locations (/System/Volumes/Data/show and /System/Volumes/Data/assets). Again, this is using NFS and assumes that you have set your shares up as NFS shares on your Sinology. SMB and AFP will be similar, but the syntax of the lines will differ a fair bit. I'm afraid I am not familiar with their settings, but a little bit of searching should get you to where you need to go.

Finally, it may be annoying that you cannot just mount directly to the root of your Mac's filesystem. That portion of the filesystem is read only (or protected in some other way that you cannot override). For this reason, if you want to mount something at the root of your Mac's filesystem you will need to edit another file called /etc/synthetic.conf. This file lets you specify symlinks at the root of the filesystem that point to whatever location you want them to. In my case, my synthetic.conf looks like this:

show    System/Volumes/Data/show
assets  System/Volumes/Data/assets

At boot time, the contents of this file are read and the symlinks are created. So in my case, I have two symlinks at / called show and assets, and they are set to point to the mounted directories I specified earlier.

Example:

-> cd /
-> ls -l
lrwxr-xr-x   1 root  wheel    26 Oct  3 23:32 assets -> System/Volumes/Data/assets
lrwxr-xr-x   1 root  wheel    24 Oct  3 23:32 show -> System/Volumes/Data/show

Make sure you change permissions on each of the files you created (auto_master, auto_nfs, synthetic.conf) files using chmod 644.

Also, Apple has a tendency to overwrite auto_master every time they update your system because of course they do. So it makes sense to create a copy and store it alongside the auto_master file for when you inevitably cannot access your data at a critical moment because Apple decided to "fix" your system.

Hope this helps.

1
  • Thanks for this! I had given up on finding an answer, and finally worked out a solution myself - very similar to yours I think, as it uses Apple's undocumented automount feature. I've been meaning to post my answer for several weeks now, but got lazy. I'm going to accept your answer, and will eventually get around to posting mine. I'd appreciate any feedback you care to give.
    – Seamus
    Commented Oct 5, 2022 at 5:46
3
+50

Here's the answer to overwriting the auto_master file after every update. For a full explanation see Automounting NFS share in OS X into /Volumes.

Issue: The auto_master file deletes added lines in the auto_master after every update macOS. The entry is overwritten by macOS security updates.

Environment: macOS 11.6 and newer.

Causes: File overwritten by macOS security updates.

Solution: To prevent the operating system from overwriting the /etc/auto_master configuration file in the future, make the file immutable: sudo chflags schg /etc/auto_master

Note: To revert changes to allow editing of the file, perform the following: sudo chflags noschg /etc/auto_master

0
2

Finally getting around to posting the solution that I worked out:

As stated in my question, I needed a persistent mount for a share on my Synology NAS (model DS1621+, DSM 7.1.1-42962). One thing I did not mention in my question is that I need a solution that works for systems that employ the read-only file system (Catalina & beyond), and for those that don't (Mojave & prior).

As it turns out, this is a fairly straightforward configuration once you understand what is going on in Apple's AutoFS... but that's made far more difficult by Apple's discontinuation of the documentation! Not to get too far off on a tangent, but I simply don't understand why Apple has removed the documentation for AutoFS, and why they seem to have abandoned development of it. If anyone has any background on this, I'd love to hear from you. In the meantime, I've managed to locate a copy of the AutoFS documentation that may be accessed here.

I. autofs for read-only file systems (Catalina & later)

Without further ado, here are the required changes for my Catalina system. Please note that the following operations require root privileges:

1. Modify the file /etc/auto_master to add one line as shown below:
#
# Automounter master map
#

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

# above is default; add this one line: 
/System/Volumes/Data/mnt/synology       auto_synology

You may choose an alternative name for synology, and auto_synology is a file containing details for the auto mount.

2. Create the file /etc/auto_synology with the following content:
syn_backup        -fstype=smbfs ://username:password@SynologyNAS-1/backups
syn_music         -fstype=smbfs ://username:password@SynologyNAS-1/music
syn_pictures      -fstype=smbfs ://username:password@SynologyNAS-1/pictures

Note the pattern: one line for each share you wish to automount; I used 3 shares in this example.

  • The first column is the share's name under the mount point (i.e. /System/Volumes/Data/mnt/synology from the /etc/auto_master entry)

  • The 2nd column specifies the network file system format as defined for the share on the Synology server; in this case I used SMB

  • The 3rd column gives the userid & password defined for a valid user account on the Synology NAS, followed by the network name (SynologyNAS-1), and the proper share name as defined on the server.

3. Run the "magic command" to immediately apply all changes :)
% sudo automount -vc

II. autofs for read-write file systems (Mojave & earlier)

The only change required is in the /etc/auto_master file. The single added line should reflect the more straightforward file system hierarchy:

# to the default auto_master file, add this one line: 
/Volumes/mnt/synology       auto_synology

The /etc/auto_synology file is identical, and the same "magic command" immediately applies all changes.

Other Ideas:

Nothing exceptional here, I only wanted to make a point about creating symbolic links to the mount points can come in handy. As I use the AutoFS feature mostly to simplify routine access to network shares, I've found it useful to create symlinks that are convenient & useful in scripts & working from the command line. For example, I have created a symlink to the directory where my rsync backups are stored. The mount point is /System/Volumes/Data/mnt/synology/syn_bkup and the directory is rsync-myMac. To easily access that location, I've created the following symlink:

% ln -s /System/Volumes/Data/mnt/synology/syn_bkup/myMac ~/rsyn_bkup
0

You must log in to answer this question.

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