Ubuntu 14.04 autofs - mount cifs network filesystem


  • mount/unmount file system.
  • understand the difference among various file systems.
  • have deep understanding on how to configure /etc/fstab.

Autofs is an alternative efficient way of mounting network shares.
It resolves the disadvantage that is caused by static/permanent mounting mechanism( using /etc/fstab on client side ) in NFS or CIFS:

  • The static mount generate unnecessary network traffic while the shares are not used. In a large network, it is costly to network bandwidth.
  • If the share servers are down or cannot be connected, it usually causes clients hung resulting client reboot.

Autofs doesn't mount the shares constantly, instead, it mounts the shares on-demand when in use and unmount the shares when NOT in use( usually, around 3 minutes depending on the default time-out value). So, when you change directory to the mount point, autofs mounts the share instantly. When no process is using the mount point, autofs unmount the mount point to save network traffic.

The following is the simplest scenario to auto mount the shares from Windows system without authentication:

  • The Windows server information:
    • IP address:
    • Shared folder : Data
  • The Ubuntu 14.04 client machine needs to:
    • Mounting point : /mnt/cifs

There are couple of files need to be modified or created:

  • /etc/auto.master : The default configuration file of autofs
  • /etc/auto.cifs.d : (needs to be created) Directory that contains mapping file
  • /etc/auto.cifs.d/cifs.autofs : (needs to be created) File that contain mapping configuration.

The following are the steps:

  1. Modify /etc/auto.master, append the following lines.
  # Added by Ben at 日  9月 20 10:44:01 CST 2015

  /mnt/cifs            /etc/auto.cifs.d/cifs.autofs
  1. Create /etc/auto.cifs.d:
  mkdir -p /etc/auto.cifs.d
  1. Create /etc/auto.cifs.d/cifs.autofs:
  touch  /etc/auto.cifs.d/cifs.autofs
  1. Put the following line into /etc/auto.cifs.d/cifs.autofs
  Data   -fstype=cifs  ://
  1. Restart autofs daemon:
  service autofs restart

Notice: Don't try to create /mnt/cifs/Data by yourself, autofs does that for you.

Then, try change directory to /mnt/cifs/Data:

  cd  /mnt/cifs/Data

If you are in /mnt/cifs/Data, congratulations! you're successful with autofs setup.