هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
/data /etc/auto.data --timeout=300projects -rw,soft,vers=4.2 nfs01.example.com:/exports/projects
archive -ro,vers=4.2 nfs01.example.com:/exports/archiveStep by step
- Install autofs and the NFS client (Debian/Ubuntu:
autofs nfs-common). - Master map (first file) — "everything under
/datais managed by the map/etc/auto.data, unmount after 300 s idle". Do not create/data/projectsyourself; autofs creates the folders. - Map file (second file) — one line per share: key (folder name under
/data), mount options, source. Check the exports first:showmount -e nfs01.example.com(NFSv3) or try a manual mount. - Start and trigger —
ls /data/projectsmounts it;ls /dataalone shows nothing until a key is used (add--browsein the master map to show all keys). - Home folders with a wildcard:
/home/remote /etc/auto.home* -rw,vers=4.2 nfs01.example.com:/exports/home/&* matches any name, & is replaced by it: /home/remote/alice mounts …/home/alice.
- See the active maps —
automount -mprints what autofs has loaded. After editing maps:systemctl reload autofs. - Debug —
journalctl -u autofs -fwhile youlsthe path; stop the service and runautomount -f -vin the foreground for verbose output.
Check that it worked
ls /data/projects lists the files; findmnt /data/projects shows nfs4 from nfs01.example.com:/exports/projects; after 5 idle minutes findmnt shows it unmounted again; ls /home/remote/alice mounts alice's home.
Common problems
| Problem | Cause | Fix |
|---|---|---|
No such file or directory on the key | Map not loaded, typo in the key, or master file not ending in .autofs. | automount -m; systemctl reload autofs. |
access denied by server | Export does not allow this client. | Fix /etc/exports on the server (exportfs -v). |
| Folder exists but is empty | You created it by hand under the autofs mount point. | Remove your own folders; let autofs create them. |
| Hangs when the server is down | Hard mount. | Use soft (careful with writes) and short timeouts; monitor the server. |
Permission denied as root on NFS | Root squash on the server. | Normal security; work as the owning user. |
| Mounts never go away | Something keeps them busy (shell in the folder). | lsof +f -- /data/projects; shorter --timeout. |
Go further
- Command pages: automount, showmount, mount, findmnt.
- Next how-tos: Share a folder with NFS, Mount a Windows or Samba share, Mount a disk at boot with fstab, Share a folder with a group using ACLs.
- Learn it: RHCSA — autofs, RHCSA — Wildcard maps, RH134 — autofs. Full guide: NFS.
1What is the advantage of autofs over fstab for NFS?
Shares are mounted only when used and unmounted when idle, so boots are fast and a down server does not block the system.
2What do * and & mean in an autofs map?
* matches any folder name that is opened, and & is replaced by that name in the source path.