Use autofs on Oracle Linux

Send lab feedback

Use autofs on Oracle Linux


The following tutorial provides step-by-step procedures to configure autofs to mount NFS shares. The benefit of autofs is the file system is mounted only when accessed. This tutorial is targeted at users of Oracle Linux.


In this lab, you'll:

  • Install nfs-utils
  • Configure an NFS server
  • Mount NFS shares

What Do You Need?

  • A client system with Oracle Linux installed.
  • An NFS server up and running with a shared data directory at /nfs-share.

Install the autofs Package

Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.

  1. Open a terminal and connect to your client instance.

  2. Install the NFS utilities and autofs packages.

    sudo dnf install -y nfs-utils autofs

    This command will install the daemon and tools associated with the NFS client and automount function.

  3. Verify the autofs files exist in the /etc directory.

    ls -lh /etc/auto*

    autofs file listing

Create Mount Point

  1. Create a directory to use as the mount point for the autofs service.

    sudo mkdir /nfs-mount

Configure a Master Map File

This is the first of two files read by the autofs service. The master map file (/etc/auto.master) contains entries in the following format:

mount-point [map-type[,format]:]map [options]

Rather than edit the main file, the service also includes and reads files conforming to this format when placed in the /etc/auto.master.d directory.

  1. Add a Master Map Entry File to /etc/auto.master.d.

    echo "/nfs-mount  /etc/auto.mynfs  --timeout=180" | sudo tee /etc/auto.master.d/mynfs.autofs > /dev/null

    This entry defines the mount point as /nfs-mount and the map file as auto.mynfs. The share will automatically unmount after 180 seconds if there no action performed on the share. The file created has an extension of .autofs.

  2. Verify the entry.

    ls -lh /etc/auto.master.d
    cat /etc/auto.master.d/mynfs.autofs

    confirm changes

For more details, check out man auto.master.

Configure a Map File

This is the second file read by the autofs service. The map files contain entries using the following format:

mount-point mount-options location

  1. Create the map file /etc/auto.mynfs.

    echo "mynfs  -fstype=nfs,rw,soft,intr  <SERVER_IP_ADDRESS>:/nfs-share" | sudo tee /etc/auto.mynfs > /dev/null


    • mynfs is a mount point.
    • -fstype=nfs is the file system type, and rw,soft,intr are mount options.
    • <SERVER_IP_ADDRESS> is the IP address of the server instance hosting the NFS server.
    • :/nfs-share is the NFS share.

For more details on the mount options, check out man mount.

Start Service

  1. Start and enable the autofs service in a single step.

    sudo systemctl enable --now autofs

    start autofs

Try to Access the Mount Point

The mount point for the NFS share is /nfs-mount/mynfs.

  1. Change to the mount point and get a directory listing.

    cd /nfs-mount/mynfs; ls -l

    get directory listing

  2. Get a file system disk usage report.

    df -Th

    df report

    The output shows the NFS share and the autofs mount point details.

More Learning Resources

Explore other labs on or access more free learning content on the Oracle Learning YouTube channel . Additionally, visit to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center .