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

    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. Posted on December 6th

      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. Posted on December 12th

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

    3. some random Googler
      Posted on December 8th

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

  • Post a Comment

    Let us know what you thought.

  • Name:

    Email (required):

    Website:

    Message:

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