• 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.
  • 4 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! :)

    4. jagdish
      Feb 10th
      Reply

      I have tried to mount my pendrive on rhel4 using the abovementioned steps. But failed. The auto.master entry is “/media /etc/auto.removable
      and the auto.removable looks as under :
      cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
      removable -fstype=ext2 :/dev/sdc1
      After this restarted the autofs service but the pen drive is not mounted. Can anybody tell me how to mount pendrive automatically.

  • Leave a Reply

    Let us know what you thought.

  • Name (required):

    Email (required):

    Website:

    Message:

Visitors have tagged this post: service (21) - rhel crontab (15) - automounter (15) - RHEL automount (12) - rhel4 autofs (12) - rhel4 automount (10) - rhel5 automount (8) - automount cdrom rhel (8) - rhel autofs (8) - t (8) - rhel5 mount cdrom (7) - automount rhel 5 (7) - RHEL4 crontab (7) - rhel automount cdrom (7) - rhel 5 automounter (7) - rhel4 auto.net (6) - autofs rhel4 (6) - rhel services (5) - autofs howto (5) - RHEL4 + NFS (5) - mss (5) - crontab RHEL (4) - automount rhel (4) - rhel5 autofs (4) - RHEL automount cd (4) - auto.master (4) - /etc/auto.net (4) - mount cdrom rhel (4) - automount rhel4 (4) - autofs RHEL (4) - nfs rhel howto (4) - RHEL automounter (4) - rhel auto.net (3) - rhel 5 mount cdrom (3) - automount cd RHEL (3) - RHEL 5 automount (3) - rhel4 services (3) - rhel automount auto.direct (3) - how to mount cdrom in rhel5 (3) - rhel auto.direct (3) - automounter rhel 4 (3) - rhel5 automounter (3) - rhel automount howto (3) - rhel 5 crontab (3) - auto.net nfs (3) - rhel5 autofs howto (3) - autofs rhel5 (3) - rhel autofs howto (3) - auto.net rhel (3) - rhel4 service (3) - RHEL 5 auto.misc (2) - Rhel 5 cdrom mounting (2) - Mounting CDrom RHEL5 (2) - rhel4 autofs ghost (2) - mount cd RHEL (2) - rhel automount restart (2) - rhel5 automount cdrom (2) - service command rhel (2) - crontab in RHEL5 (2) - +rhel +"auto mount" (2) - mount nfs in rhel 5 (2) - howto autofs /net (2) - crontab rhel4 (2) - autofs rhel4 options (2) - crontab format rhel (2) - rhel, automount service (2) - auto mount cd on rhel (2) - howto configure autofs in RHEL AS4 (2) - rhel automount auto direct (2) - cron format howto (2) - automount rhel 4 (2) - automount service rhel (2) - automount options RHEL 4 (2) - RHEL autofs example (2) - rhel4 auto.direct (2) - can not mount cd rhel 4 (2) - auto.net automount (2) - auto.net example (2) - setting up autofs with rhel 5 (2) - autofs direct mapping RHEL5 (2) - rhel4 nfs automount (2) - RHEL4 automount cdrom (2) - auto.direct RHEL (2) - rhel not automounting cd (2) - automounting in RHEL 5 (2) - RHEL5 auto.master (2) - rhel 4 automount (2) - Setting up autofs (2) - automount rhel cdrom (2) - setting up nfs rhel (2) - rhel automatically mount cdrom (2) - linux rhel4 automount (2) - rhel5 auto.net (2) - chkconfig mount (2) - /ETC/AUTO.MISC (2) - mount cdrom in RHEL (2) - autofs RHEL 4 (2) - rhel5 mount floppy (2) - rhel service command (2) - rhel (2) - /net and automaster (2) - automounter RHEL4 (2) - mount cdrom rhel5 (2) - solaris (2) - nfs (2) - mounting CD in rhel (2) - autofs-5 rpm (2) - how to mount cdrom RHEL5 (2) - mount ftp in rhel (2) - rhel5 net automount (2) - automounting on RHEL AS4 (2) - linux automount rhel (2) - Automount RHEL5 (2) - automount cd rhel 3 (2) - RHEL5 "/misc" directory (2) - rhel mount cdrom (1) - setting autofs (1) - RHEL 5 CD mount (1) - rhel autofs program map (1) - rhel5 automount cd as root (1) - RHEL 3 nfs version 3 mount (1) - rhel nfs howto (1) - solaris 10 automount cdrom /dev/cdrom (1) - linux nfs /etc/auto.net (1) - RHEL 5 mount (1) - linux automount net (1) - linux automount nfs on boot bash script (1) - RHEL cdrom mount (1) - autofs /home howto rhel5 (1) - RHEL automount autofs (1) - CDROM automounting in RHEL 5 (1) - montage nfs RHEL 5 (1) - auto.misc nfs3 (1) - rhel mounting cdrom (1) - automount startup RHEL 4 (1) - rhel4 cdrom mount point (1) - mount cdrom on rhel5 (1) - automount cdrom rhel5 (1) - rhel4 automount auto.net (1) - autofs in RHEL5 (1) - rhel autofs OR automounter (1) - automount linux rhel (1) - create automount filesystem RHEL (1) - service autofs status (1) - cron rhel (1) - automounting CDROM in RHEL 5 (1) - automount direct linux example (1) - setting up auto.misc (1) - automount root directory RHEL4 (1) - autofs rhel5 change (1) -