Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

automount

The autofs daemon: mounts file systems (mostly NFS) when they are used and unmounts them when idle. Managed with systemctl; the command helps debugging.

Niveau
RHCSA-examen
Groep
Schijven en bestandssystemen
Root nodig
Ja
Pakket
autofs

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

autofs runs as autofs.service. The master map (/etc/auto.master and /etc/auto.master.d/*.autofs) lists base folders and map files; map files list keys, options and sources. * and & make one line work for many folders (home folders). After changing maps, restart or reload autofs. automount -m prints all maps as autofs sees them.

Zo schrijf je het

automount [OPTION]... [MASTER_MAP]

Belangrijkste delen

/base /etc/auto.NAME
Master map line: indirect mounts under /base.
/- /etc/auto.direct
Master map line: direct mounts (full paths in the map).
key -options server:/path
Map line (indirect).
/full/path -options server:/path
Map line (direct).
* -rw server:/home/&
Wildcard: & is the key that was asked for.
--timeout=N
In the master map: unmount after N idle seconds.

Opties 18

Meest gebruikt

-m, --dumpmaps [TYPE NAME]
Print the maps and exit.
-f, --foreground
Run in the foreground (debug).
-d[LEVEL], --debug[=LEVEL]
Debug output.
-v, --verbose
Verbose log.
-t, --timeout SECONDS
Default idle timeout (600).
-n, --negative-timeout SECONDS
Cache time for failed lookups.
-M, --master-wait SECONDS
Wait for the master map at start.
-D VARIABLE=VALUE, --define VARIABLE=VALUE
Define a map variable.
-p, --pid-file FILE
PID file.
-r, --random-multimount-selection
Random server choice for replicated mounts.
-O, --global-options OPTIONS
Options added to all mounts.
-l, --set-log-priority PRIORITY PATH
Change the log level of a running daemon for a path.
-S, --systemd-service
Run as a systemd service.
-C, --dont-check-daemon
Do not check for a running daemon.
-F, --force
Force unlink of old mount points at start.
-U, --force-exit
Force exit, unmount everything.
-h, --help
Show help.
-V, --version
Show the version.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1Install and start

    dnf install -y autofs
    systemctl enable --now autofs

    Reads the master map.

  2. 2Indirect map

    cat /etc/auto.master.d/shares.autofs /etc/auto.shares
    /shares /etc/auto.shares
    data -rw server2:/exports/data

    /shares/data mounts on first use.

  3. 3Home folders with a wildcard

    cat /etc/auto.rhome
    * -rw server2:/exports/home/&

    /rhome/lisa → server2:/exports/home/lisa.

  4. 4Apply map changes

    systemctl restart autofs

    Or systemctl reload autofs for map file changes.

  5. 5Show what autofs knows

    automount -m

    All maps after parsing.

  6. 6Trigger and check a mount

    ls /shares/data; findmnt /shares/data

    The folder appears only when used.

  7. 7Debug a failing map

    systemctl stop autofs; automount -f -d

    Foreground with debug output; then ls /shares/data in another terminal.

  8. 8Unmount after 60 seconds

    echo "/shares /etc/auto.shares --timeout=60" > /etc/auto.master.d/shares.autofs

    Shorter idle time.

  9. 9Direct map

    cat /etc/auto.direct
    /srv/projects -rw,soft server2:/exports/data

    Master map line: /- /etc/auto.direct.

  10. 10Logs

    journalctl -u autofs --since -10min

    Errors like "mount(nfs): nfs: mount failure".

Bestanden

/etc/auto.master, /etc/auto.master.d/*.autofs
Master map.
/etc/auto.*
Map files.
/etc/autofs.conf
Daemon settings.

Exitcodes

0Done.
1Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man 8 automount