• Setting Up The Automounter Service on RHEL

    Mounting 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.

    This entry was posted on Wednesday, December 6th, 2006 at 12:23 pm and is filed under Data and Technology. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
  • 3 Comments

    Take a look at some of the responses we've had to this article.

    1. Dec 6th
      Reply

      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. Dec 12th
      Reply

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

    3. some random Googler
      Dec 8th
      Reply

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

  • Leave a Reply

    Let us know what you thought.

  • Name (required):

    Email (required):

    Website:

    Message:

Visitors have tagged this post: automounter (15) - rhel4 autofs (12) - rhel crontab (11) - rhel4 automount (10) - RHEL automount (9) - rhel5 automount (8) - automount cdrom rhel (8) - t (8) - RHEL4 crontab (7) - automount rhel 5 (7) - rhel automount cdrom (7) - rhel 5 automounter (7) - rhel5 mount cdrom (7) - rhel autofs (6) - autofs rhel4 (6) - rhel4 auto.net (6) - rhel services (5) - RHEL4 + NFS (5) - autofs howto (5) - mss (5) - service (5) - automount rhel (4) - RHEL automount cd (4) - nfs rhel howto (4) - autofs RHEL (4) - rhel5 autofs (4) - auto.master (4) - RHEL automounter (4) - /etc/auto.net (4) - automount rhel4 (4) - rhel auto.direct (3) - rhel 5 mount cdrom (3) - auto.net nfs (3) - rhel automount howto (3) - how to mount cdrom in rhel5 (3) - auto.net rhel (3) - rhel4 services (3) - rhel5 automounter (3) - automount cd RHEL (3) - mount cdrom rhel (3) - RHEL 5 automount (3) - crontab RHEL (3) - rhel automount auto.direct (3) - rhel5 autofs howto (3) - rhel autofs howto (3) - rhel4 service (3) - rhel not automounting cd (2) - solaris (2) - howto autofs /net (2) - rhel, automount service (2) - automount rhel cdrom (2) - rhel auto.net (2) - crontab format rhel (2) - howto configure autofs in RHEL AS4 (2) - rhel automount restart (2) - linux rhel4 automount (2) - rhel5 net automount (2) - rhel5 automount cdrom (2) - can not mount cd rhel 4 (2) - auto.net automount (2) - setting up autofs with rhel 5 (2) - RHEL5 "/misc" directory (2) - rhel 5 crontab (2) - +rhel +"auto mount" (2) - mount ftp in rhel (2) - rhel5 auto.net (2) - autofs rhel4 options (2) - linux automount rhel (2) - Mounting CDrom RHEL5 (2) - rhel4 nfs automount (2) - rhel5 mount floppy (2) - crontab rhel4 (2) - automount service rhel (2) - RHEL autofs example (2) - service command rhel (2) - cron format howto (2) - mounting CD in rhel (2) - mount cdrom rhel5 (2) - RHEL4 automount cdrom (2) - auto.direct RHEL (2) - rhel4 auto.direct (2) - Rhel 5 cdrom mounting (2) - automounting in RHEL 5 (2) - crontab in RHEL5 (2) - mount cd RHEL (2) - automount rhel 4 (2) - autofs direct mapping RHEL5 (2) - rhel (2) - Setting up autofs (2) - mount cdrom in RHEL (2) - /ETC/AUTO.MISC (2) - rhel4 autofs ghost (2) - automounting on RHEL AS4 (2) - automounter RHEL4 (2) - autofs-5 rpm (2) - how to mount cdrom RHEL5 (2) - automount cd rhel 3 (2) - rhel automount auto direct (2) - setting up nfs rhel (2) - rhel automatically mount cdrom (2) - automount options RHEL 4 (2) - Automount RHEL5 (2) - nfs (2) - rhel 4 automount (2) - autofs RHEL 4 (2) - RHEL 5 auto.misc (2) - RHEL5 auto.master (2) - rhel service command (2) - chkconfig mount (2) - automount in linux rhel4 (1) - enabling ftp services in RHEL AS 4 (1) - auto.misc soft intr (1) - rhel mounting cd (1) - rhel4 set up nfs server (1) - how to mount cdrom in RHEL 5 (1) - example mount rhel4 + 2003 (1) - rhel5 mounting a cdrom (1) - cron example rhel (1) - cdrom not auto mount solaris 8 (1) - RHEL 3 crontab howto (1) - rhel 5 how to mount floppy? (1) - automount auto.net timeout (1) - automount auto.net example (1) - solaris 10 automount cdrom /dev/cdrom (1) - rhel remove cd from automount (1) - rhel5 cdrom does not mount (1) - enable /net auto.master Redhat EL 5 (1) - crontab setting for RHEL4 (1) - mount floppy rhel (1) - automount howto rhel 5 (1) - service for automount (1) - linux nfs /etc/auto.net (1) - linux automount nfs on boot bash script (1) - auto.master disconnect (1) - setting autofs (1) - boot net:1 solaris (1) - linux automount net (1) - autofs net rhel (1) - RHEL 5 mount (1) - RHEL 5 CD mount (1) - rhel autofs program map (1) - cron rhel (1) - automount direct linux example (1) - RHEL 3 nfs version 3 mount (1) - nfs mount howto rhel (1) - automount examples (1) - rhel5 automount home (1) - rhel4 cannot automount cd (1) - automount direct links (1) - linux automount solaris (1) -