• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Mount NFS File Systems Using ‘autofs’ in CentOS/RHEL

By admin

This post explains how to configure ‘autofs’ in order to mount NFS file systems with ‘autofs’ service.

1. Stop ‘autofs’ service, check if the service is running then proceed to stop it.

# service autofs status
automount (pid 25285) is running...
# service autofs stop
Stopping automount: [ OK ]
# service autofs status
automount is stopped

2. Edit the /etc/auto.master file to set the file map:

The file /etc/auto.master is the main configuration file for ‘autofs’ service, this file contains the master map lists of the mount points on the system controlled by ‘autofs’, and their corresponding configuration files or network sources which are known as ‘automount maps‘.

This is how the file should looks like:

# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
#
/misc /etc/auto.misc     ---------------------> MAP FILE
#
# NOTE: mounts done from a hosts map will be mounted with the
# "nosuid" and "nodev" options unless the "suid" and "dev"
# options are explicitly given.
#
/net -hosts
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master

The ‘map file’ can be changed to any other file under /etc with the name ‘auto.mount’ in order to mount the export to any other desired directory. For more information please proceed to step number two.

Edit the ‘auto.master‘ file and add the hash symbol in front of the line “/misc /etc/auto.misc”, then proceed to add the following line to the end of the file:

/- /etc/auto.mount

The file should look like the following example after the change:

#
# /misc /etc/auto.misc
#
/- /etc/auto.mount

3. Create and/or edit the map file:

The map file is a separate file that defines the file systems to be mounted under any specified mount point. For example, the /etc/auto.misc file might define mount points in the /misc directory; another example is to use /mnt as another directory to mount the export. If any other directory is needed then a new file must be created under /etc/ directory with the name ‘auto.mount’ as a recommendation.

The following is an example of the ‘/etc/auto.misc’ file and the new file ‘auto.mount’

# This is an automounter map and it has the following format
# key(mount-point) [ -mount-options-separated-by-comma ] location   ===> THIS IS THE GENERAL FORMAT OF THE MAPS
# Details may be found in the autofs(5) manpage

cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom  ===> EXAMPLE

# the following entries are samples to pique your imagination
#linux -ro,soft,intr ftp.example.org:/pub/linux
#boot -fstype=ext2 :/dev/hda1
#floppy -fstype=auto :/dev/fd0
#floppy -fstype=ext2 :/dev/fd0
#e2floppy -fstype=ext2 :/dev/fd0
#jaz -fstype=ext2 :/dev/sdc1
#removable -fstype=ext2 :/dev/hdd

mount_point_name      -rw,soft,intr,rsize=8192,wsize=8192       NFS.example.net:/export_name  ===> IP address can be used instead of the FQDN

If you do not want to use /misc directory nor the ‘auto.misc’ file, create a new file with the name ‘auto.mount’ and add the same parameters with the corresponding syntax, like in the example as follows:

# vi /etc/auto.mount

Append the following line:

/mount_point -fstype=nfs,rw NFS.example.net:/export_name
NOTE: Make sure that you have edited the ‘/etc/auto.master’ file and change the map file to the desired one.

4. Start the ‘autofs’ service:

# service autofs start
Starting automount: [ OK ]

5. Run ‘mount’ command to check that your NFS share is now mounted:

# mount
NFS_IP_Address:/export on /mount_point  type nfs (rw,vers=4,addr=NFS_IP_Address,clientaddr=local_IP_Address)

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How to configure the logging of failed login attempts for vsftpd
  2. CentOS / RHEL 7 : sysctl kernel parameter doesn’t take effect after reboot
  3. Linux OS Service ‘microcode_ctl’
  4. How to configure DM-Multipath from an iSCSI initiator to an iSCSI target in CentOS / RHEL
  5. CentOS / RHEL 6 : How to add/remove additional IP addresses to a network interface
  6. How to configure kdump in Oracle Enterprise Linux (OEL 5,6)
  7. Linux / UNIX : Examples of find command to find files with specific sets of permissions
  8. How to fix the error “host key verification failed”
  9. How to change the number of commands stored in Bash History
  10. RHEL / CentOS : How to rebuild LVM from Archive (metadata backups)

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable ACPI in CentOS/RHEL 7
  • How to Use real-time query to access data on a physical standby database
  • CentOS/RHEL 8: “ACPI MEMORY OR I/O RESET_REG” Server Hung after reboot
  • How to Create a Physical Standby Database by Using SQL and RMAN Commands
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary