AutoFS

From Segfault
Jump to: navigation, search

Linux

Add a map file to /etc/auto.master:

+auto.master

/mnt/smb /etc/auto.cifs
/mnt/nfs /etc/auto.nfs

Add the file systems to be mounted to respective map file:

$ cat /etc/auto.nfs
foo  -fstype=nfs,rw,nodev,nosuid,noexec,bg,intr,sec=sys  host1:/mnt/foo
bar  -fstype=nfs,ro,nodev,nosuid,noexec,bg,intr,sec=sys  host2:/mnt/bar

With that in place, autofs should just work:

$ ls -go /mnt/nfs
total 0

$ ls -go /mnt/nfs/foo
total 92
drwx--x--x 11  4096 Dec  7 00:10 dir0
drwxr-xr-x  8  4096 Jan  2 16:11 dir1
drwxr-xr-x 88  4096 Dec 31  2013 dir2

MacOS

We can use the auto_master file or DiskUtility to get automount(8) working.

auto_master

Let's create the mount points first, both for SMB and NFS:

mkdir -p /mnt/{nfs,smb}/{a,b}

Then we create automount maps for each protocol:

$ cat /etc/auto_nfs 
/mnt/nfs/a -fstype=nfs,rw,resvport 10.0.0.10:/export/foo
/mnt/nfs/b -fstype=nfs,ro,resvport 10.0.0.10:/export/bar

$ cat /etc/auto_smb 
/mnt/smb/a -fstype=smbfs,rw ://10.0.0.10/foo
/mnt/smb/b -fstype=smbfs,ro ://10.0.0.10/bar

With that in place, we have to include both files in auto_master(5):

$ grep -v ^\# /etc/auto_master
+auto_master            # Use directory service
/-                      auto_smb
/-                      auto_nfs

Tell automountd(8) to flush any cached information:

automount -v -c

Sometimes it's necessary to restart automountd:

launchctl stop  com.apple.autofsd
launchctl stop  com.apple.automountd
launchctl start com.apple.automountd
launchctl start com.apple.autofsd

DiskUtility

We can try the same with Disk Utility. Let's create the mount point first:

$ mkdir /mnt/nfs/a

Open DiskUtility:

$ open -a Disk\ Utility
  1. Click FileNFS Mounts'
  2. Click + to add a new NFS mount
  3. Remote NFS URL should be something like nfs://10.0.0.2/mnt/backup/data
  4. Mount Location should be something like /mnt/nfs/a
  5. We might have to add resvport to the Advanced Mount Parameters
  6. Click Verify
  7. Click Close

The new mounts should be available immediately.

Solaris

TBD...

Links