Filesystem Administration  «Prev  Next»

Lesson 5 Setting up the automounter
Objective Set up the automounter.

Setting up Automounter in Red Hat

The automounter is still used in Red Hat Enterprise Linux (RHEL) 9.4, but it has been modernized and is typically implemented using the autofs service. The automounter is a system tool that allows automatic mounting and unmounting of file systems on demand, which is particularly useful in environments with shared resources like NFS (Network File System). Here are some key points about the automounter in RHEL 9.4:
  1. Autofs Package:
    • The automounter functionality is provided by the autofs package.
    • You can verify its installation with:
      rpm -q autofs
              
    • If it's not installed, you can add it with:
      sudo dnf install autofs
              
  2. Configuration:
    • The primary configuration file for autofs is located at /etc/auto.master. Additional mount points can be defined in separate map files. For example:
    • /etc/auto.master might include:
      /mnt/nfs /etc/auto.nfs
              
    • /etc/auto.nfs could map specific directories to NFS shares.
  3. Usage and Commands:
    • Start or enable the autofs service:
      sudo systemctl start autofs
      sudo systemctl enable autofs
              
    • Check the status of the service:
      sudo systemctl status autofs
              
  4. On-Demand Mounting:
    • When a file system is accessed (e.g., navigating into a directory), the automounter will mount it.
    • If the file system is idle for a configured timeout period, the automounter will unmount it.
  5. Modern Alternatives:
    • While autofs is still widely used, newer technologies like systemd.automount units can also provide similar functionality with integration into the systemd ecosystem.
  6. RHEL Documentation:
    • Red Hat's official documentation includes guides for configuring and managing autofs in RHEL 9.4.

amd vs. autofs

The two Linux automounters that can be configured and used on the Red Hat Linux system are:
  1. autofs
  2. systemd.automount

amd is not an automounter, but a package manager for AMD64 systems. autofs is the traditional automounter for Linux. It has been around for many years and is very powerful and flexible. However, it can be complex to configure.
systemd.automount is a newer automounter that is integrated with the systemd system and service manager. It is simpler to configure than autofs, but it is not as powerful. Which automounter you choose depends on your needs and preferences. If you need a powerful and flexible automounter, autofs is a good choice. If you need a simpler and easier-to-configure automounter, systemd.automount is a good choice.
Here is a table comparing the two automounters:
Feature autofs systemd.automount
Maturity Mature Newer
Power and flexibility Powerful and flexible Less powerful and flexible
Complexity Complex to configure Simpler to configure
Integration with systemd Not integrated Integrated


Automounters in Red Hat Linux

On Red Hat Linux, two commonly used automounters can be configured and used.
  1. Autofs
    • Description: Autofs is the most commonly used automounter in Red Hat Linux. It dynamically mounts file systems as they are accessed and unmounts them when they are no longer in use, based on a configurable timeout period.
    • Features:
      • Works with NFS, CIFS, and other file systems.
      • Configuration is done through /etc/auto.master and associated map files.
      • Can handle both direct and indirect mappings for file system mounts.
    • Relevant Commands:
      • Start/enable the service:
        sudo systemctl start autofs
        sudo systemctl enable autofs
                    
      • Configuration file location: /etc/auto.master.
  2. Systemd Automount
    • Description: Starting with systemd-based distributions, systemd.automount units can also be used as an automounter. This approach integrates tightly with the systemd ecosystem.
    • Features:
      • Uses .automount and .mount unit files for configuration.
      • Provides on-demand mounting and unmounting similar to autofs.
      • Ideal for modern environments where systemd is already managing other services and resources.
    • Relevant Commands:
      • Example to create an automount unit:
        sudo nano /etc/systemd/system/mnt-nfs.mount
                    
        Unit file content:
        [Unit]
        Description=NFS mount
        After=network.target
        
        [Mount]
        What=server:/export
        Where=/mnt/nfs
        Type=nfs
        
        [Install]
        WantedBy=multi-user.target
                    
      • Enable the automount unit:
        sudo systemctl enable mnt-nfs.mount
        sudo systemctl start mnt-nfs.mount
                    

Comparison
Feature Autofs Systemd Automount
Ease of Use Simpler to configure for NFS Requires familiarity with systemd units
Integration Independent Fully integrated with systemd
Dynamic Mounting Yes Yes
Timeout Configuration Configurable Configurable through options

Both solutions can be used effectively, depending on the system's requirements and the administrator's preference.
amd and autofs.
amd is user-level and requires no kernel support; autofs requires kernel support, but is simpler to administer. autofs kernel support is built into the stock kernel installed by the Red Hat Linux distribution. However, the autofs RPM must be installed and local configuration may be required. map file definition: "in automounter parlance, a configuration file that associates a directory key with a device to mount when that directory key is accessed." autofs has a master configuration file and a second type of configuration file, a map file for each autofs filesystem mount point.
  • autofs master file | Entry in /etc/auto.master
    The master configuration file /etc/auto.master contains the overall automount configuration, illustrated in the following diagram.
    automatster over
    Detailed information regarding the master configuration file is displayed below.

  1. This is the mount point, the location where the autofs filesystem associated with map will be mounted on the local filesystem, in this case, /misc
  2. This is the map file associated with the autofs filesystem. The map file contains entries for the devices to be mounted on the mount point
  3. These are options associated with all the devices listed in the map file. In this case, all devices listed in /etc/auto.misc automatically will be unmounted after 60 seconds of disuse


autofs map file

The map file /etc/auto.misc has entries such as the following:
1) cd, 2) floppy, 3) -fstype=iso9660,ro, 4) -fstype=auto, 5) :/dev/cdrom. 6) :/dev/fd0
1) cd, 2) floppy, 3) -fstype=iso9660,ro, 4) -fstype=auto, 5) :/dev/cdrom. 6) :/dev/fd0

Entry in /etc/auto.misc

AMD

amd is the file system automounter daemon. It automatically mounts an unmounted file system whenever a file or directory within that file system is accessed. File systems are automatically unmounted again after a period of disuse. This file is where you would add amd options to be run every time by amd. Options include specifying where amd activity should be logged, and specifying how long amd should wait before umounting an idle file system.

1) cd, 2) floppy, 3) -fstype=iso9660,ro, 4) -fstype=auto, 5) :/dev/cdrom. 6) :/dev/fd0
1) cd, 2) floppy, 3) -fstype=iso9660,ro, 4) -fstype=auto, 5) :/dev/cdrom. 6) :/dev/fd0

  1. The mount point used to access the device. In this case, /misc/cd.
  2. Mounting options. In this case, the drive is configured for standard, read-only CD-ROMS.
  3. The location of the filesystem to mount. In this case, it is the local CD-ROM drive, cdrom. The colon indicates that the drive is a local device.
  4. The mount point used to access the device. In this case, /misc/floppy.
  5. Mounting options. In this case, the drive is configured to automatically recognize the type of disk and mount it appropriately. For example, a floppy can be formatted for DOS or Linux.
  6. The location of the filesystem to mount. In this case, it is the first local floppy drive, fd0.The colon indicates that the floppy is a local device.


Other options

/etc/rc.d/init.d/autofs status
will report the status and location of all automounter active mount points. Other options that can be used with autofs include start, stop, and reload, which perform the obvious actions. For example,
/etc/rc.d/init.d/autofs stop

will stop the automounter and deactivate any currently active automatic mount points.
If you make changes to the automounter, you should reboot to verify that it comes up. If it fails, you should make autofs automatically run with the command chkconfig, add autofs.

SettingUp Automounter


The following paragraph checks your understanding of how to set up the automounter.

Setting up automounter

This exercise asked you to simulate the process required to install and configure the automounter to automount your CD-ROM and make it accessible at
/local_cd
. The following screen illustrates the results.
File systems
  1. Kernel automounter version 4 support (also supports v3) N
  2. Ext3 journalling file system support

Simulation result
Simulation result

The next lesson describes network file synchronization.

SEMrush Software 5 SEMrush Banner 5