Setting Up The Automounter Service on RHEL

linux.jpgMounting filesystems in RHEL is pretty straightforward and easy. Occasionally, however, you will not want the filesystem to remain mounted all the time, but rather to automatically mount for a set period of time only when it is needed. Because of networking overhead, and the general unreliability of networks, NFS mounts are a good example of when this can be especially useful.

In order to manage the automatic mounting and unmounting of filesystems on RHEL, we use the Automounter service. Here is how.

First, The main configuration file is “/etc/auto.master”. It should look something like this:

#
# $Id: auto.master,v 1.3 2003/09/29 08:22:35 raven Exp $
#
# 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 --timeout=60
#/misc  /etc/auto.misc
#/net   /etc/auto.net


Let’s assume that we want to set up an NFS mount on “/misc/backups”. We would first create an entry in this file that looks something like this:

/misc   /etc/auto.misc --timeout=120


This tells the autofs service that we want to use it to manage mounts from within “/misc”, that the configuration file is “/etc/auto.misc”, and that it should disconnect after 2 minuets of inactivity.

Now, let’s edit the “/etc/auto.misc” file. The file has three columns: the mount point from within the /misc directory, the options for mounting the filesystem, and the filesystem to be mounted. It also includes the remote server’s name since we are using NFS. It should look something like this when you are done:

#
# $Id: auto.misc,v 1.2 2003/09/29 08:22:35 raven Exp $
#
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
backups         -rw,soft,intr remoteservername:/path/to/nfs/export

# 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


Next, we create the directory for the mount point in /misc:

# mkdir /misc/backups

And finally we restart the autofs service:

# service autofs restart

That should pretty much do it. If you don’t have autofs configured to start up, you can use chkconfig to enable it. “/misc/backups” will now be mounted whenever a user or process attempts to access data on it, and it will be automatically disconnected after 120 seconds of inactivity. Last, but not least, you can always confirm that it is running with the “service” command:

# service autofs status

As always, change the details to match your own requirements.

Discuss This Article


3 Responses to “Setting Up The Automounter Service on RHEL”

  1. Mike D on December 6th, 2006 8:22 pm #

    About a year ago I was looking for just such a mechanism, but I never found out about autofs. What I did was put “0 * * * * /bin/mount -a -t nfs” in root’s crontab. It’s ugly, and I think I’ll replace it with autofs.

  2. cliff on December 12th, 2006 4:10 pm #

    I’m glad it was helpful Mike… By the way, what happened to your blog?

  3. some random Googler on December 8th, 2007 5:54 am #

    Thanks!!
    My wife is much happier about editing our website now! :)


Got something to say?






Post Tags (user submitted): rhel4 autofs (12) - rhel crontab (11) - rhel4 automount (10) - automount cdrom rhel (8) - rhel5 automount (8) - t (8) - RHEL automount (8) - automount rhel 5 (7) - rhel automount cdrom (7) - rhel5 mount cdrom (7) - RHEL4 crontab (7) - rhel 5 automounter (7) - rhel4 auto.net (6) - rhel autofs (6) - autofs rhel4 (6) - RHEL4 + NFS (5) - autofs howto (5) - automounter (5) - mss (5) - rhel services (5) - auto.master (4) - RHEL automount cd (4) - automount rhel (4) - /etc/auto.net (4) - rhel5 autofs (4) - automount rhel4 (4) - RHEL automounter (4) - autofs RHEL (4) - automount cd RHEL (3) - rhel automount howto (3) - rhel5 autofs howto (3) - rhel automount auto.direct (3) - rhel5 automounter (3) - rhel4 services (3) - nfs rhel howto (3) - rhel auto.direct (3) - RHEL 5 automount (3) - auto.net nfs (3) - rhel autofs howto (3) - how to mount cdrom in rhel5 (3) - auto.net rhel (3) - crontab RHEL (3) - rhel4 service (3) - linux automount rhel (2) - autofs RHEL 4 (2) - rhel automatically mount cdrom (2) - rhel4 auto.direct (2) - setting up nfs rhel (2) - mount cdrom in RHEL (2) - rhel5 automount cdrom (2) - cron format howto (2) - mount ftp in rhel (2) - RHEL 5 auto.misc (2) - Rhel 5 cdrom mounting (2) - rhel auto.net (2) - crontab format rhel (2) - auto.net automount (2) - can not mount cd rhel 4 (2) - rhel 4 automount (2) - autofs direct mapping RHEL5 (2) - howto configure autofs in RHEL AS4 (2) - automounting on RHEL AS4 (2) - crontab in RHEL5 (2) - automount rhel 4 (2) - RHEL5 auto.master (2) - service command rhel (2) - mount cdrom rhel5 (2) - mounting CD in rhel (2) - automount service rhel (2) - mount cdrom rhel (2) - rhel5 auto.net (2) - Mounting CDrom RHEL5 (2) - RHEL5 "/misc" directory (2) - rhel not automounting cd (2) - automount rhel cdrom (2) - crontab rhel4 (2) - RHEL4 automount cdrom (2) - rhel 5 mount cdrom (2) - +rhel +"auto mount" (2) - autofs rhel4 options (2) - RHEL autofs example (2) - automount cd rhel 3 (2) - automounting in RHEL 5 (2) - linux rhel4 automount (2) - rhel5 net automount (2) - rhel4 nfs automount (2) - auto.direct RHEL (2) - rhel5 mount floppy (2) - rhel, automount service (2) - automount options RHEL 4 (2) - Setting up autofs (2) - setting up autofs with rhel 5 (2) - solaris (2) - /ETC/AUTO.MISC (2) - rhel (2) - rhel automount auto direct (2) - autofs-5 rpm (2) - rhel 5 crontab (2) - rhel automount restart (2) - howto autofs /net (2) - rhel service command (2) - rhel4 autofs ghost (2) - nfs (2) - automounter RHEL4 (2) - chkconfig mount (2) - Auto mount cd drive in RHEL5 (1) - setting up Solaris auto mounter (1) - rhel4 mount cdrom (1) - autofs rhel howto (1) - enable ftp in RHEL 5 (1) - howto rhel 5 (1) - sample auto.direct (1) - setting up auto.master (1) - nfs solaris timeout disconnect mount (1) - what is the command for FTP service in RHEL 5 (1) - rhel++AS4++setting++ftp (1) - rhel4 services needed for nfs (1) - mount cdrom rhel 5 automatically (1) - rhel autofs cdrom (1) - auto.misc options (1) - automounter in rhel5 (1) - rhel nfs cdrom (1) - rhel 5 auto mount (1) - rhel5 mount automount (1) - "/net /etc/auto.net "" (1) - how to mount cd rhel (1) - cron in rhel (1) - RHEL 5 NFS mounts (1) - auto.direct in linux (1) - autofs configure rhel5 (1) - automounting CDROM in RHEL5 (1) - crontab format boot (1) - linux start service automount (1) - rhel4 start automount (1) - cdrom not auto mount solaris 8 (1) - rhel 5 drive automount (1) - rhel 5 how to mount floppy? (1) - crontab RHEL 5 (1) - automount auto.net timeout (1) - automount howto rhel 5 (1) - rhel remove cd from automount (1) - rhel5 cdrom does not mount (1) - linux "/net" auto.master (1) - linux configure auto direct maps (1) - RHEL, automount nfs (1) - rhel4 automount cd-rom (1) - restart automount service (1) - rhel autofs server (1) - rhel4 setup automount (1) - RHEL5 nfs3 (1) -