Auto mount CephFS with autofs

In order to ensure any mount is available the usage of /etc/fstab is not enough, what happens if the mount is not accessible at boot time or if the network is down for any reason.

autofs is a service that will monitor any usage of the mount resource and it will try to mount it at that time.

Install package

First install the package, for instance in Ubuntu or any Debian OS:

sudo apt install autofs


Suppose we need to mount a CephFS onto /mnt/ceph, we need to edit two files.

First we need to create the mount the /etc/auto.misc adding to the end of the file:

ceph -fstype=ceph,name=admin,secretfile=/etc/ceph/secret,noatime,,

Several things are configured here:

  • Name: ceph is the name of the element, used later to be mounted at /mnt/ceph folder.
  • Options (separated by , character):
    • file system type: ceph
    • Ceph client user name: admin
    • Secret file: filename of the client secret, I use /etc/ceph/secret but adapt to your settings
  • CephFS server settings (separated by : character):
    • List of IPs (or hostnames) of the CephFS managers, I use,, but adapt to your situation
    • CephFS folder at server side to mount, I use /docker but change it yo your settings

Then edit /etc/auto.master adding at the end of the file:

/mnt /etc/auto.misc --timeout 60

We configure here:

  • Absolute path for the mounts in the next file, I use /mnt (combined with name in previous file to conform full path of the mount resource at /mnt/ceph)
  • File with the mounts: /etc/auto.misc (previous file)
  • Timeout fot the mount tries, I use 60 seconds

Apply changes & test

Just restart autofs service:

sudo service autofs restart

Then just use the folder to mount it, for instance:

ls /mnt/ceph


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.