Questo articolo spiega come configurare 'autofs' per montare filesystem NFS tramite il servizio autofs.
1. Ferma il servizio 'autofs': verifica se è in esecuzione e poi arrestalo.
# service autofs status automount (pid 25285) is running... # service autofs stop Stopping automount: [ OK ] # service autofs status automount is stopped
2. Modifica il file /etc/auto.master per impostare la mappa dei file. Il file /etc/auto.master è il file di configurazione principale del servizio 'autofs': contiene l'elenco dei mount point gestiti da 'autofs' e i corrispondenti file di configurazione o sorgenti di rete, noti come 'automount maps'. Ecco come dovrebbe presentarsi:
# 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 --------------------> MAP FILE # # NOTE: mounts done from a hosts map will be mounted with the # "nosuid" and "nodev" options unless the "suid" and "dev" # options are explicitly given. # /net -hosts # # Include central master map if it can be found using # nsswitch sources. # # Note that if there are entries for /net or /misc (as # above) in the included master map any keys that are the # same will not be seen as the first read key seen takes # precedence. # +auto.master
La 'map file' può essere cambiata con qualunque altro file in /etc chiamato 'auto.mount', per montare l'export in qualsiasi altra directory desiderata.
Modifica il file 'auto.master' e aggiungi il simbolo cancelletto davanti alla riga «/misc /etc/auto.misc», poi aggiungi la riga seguente alla fine del file:
/- /etc/auto.mount
Dopo la modifica il file dovrebbe presentarsi così:
# /misc /etc/auto.misc #- /etc/auto.mount
Attenzione: la sintassi corretta è «/- /etc/auto.mount», dove «/-» indica una mappa di tipo direct map.
/- /etc/auto.mount
3. Crea e/o modifica il file di mappa. Il file di mappa è un file separato che definisce i filesystem da montare sotto un determinato mount point. Per esempio, /etc/auto.misc può definire mount point nella directory /misc; in alternativa puoi usare /mnt. Se serve un'altra directory, crea un nuovo file in /etc con il nome 'auto.mount', come da nostra raccomandazione.
Di seguito un esempio di file '/etc/auto.misc' e del nuovo file 'auto.mount':
# This is an automounter map and it has the following format # key(mount-point) [ -mount-options-separated-by-comma ] location # ===> THIS IS THE GENERAL FORMAT OF THE MAPS # Details may be found in the autofs(5) manpage cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom ===> EXAMPLE # 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 mount_point_name -rw,soft,intr,rsize=8192,wsize=8192 NFS.example.net:/export_name ===> IP address can be used instead of the FQDN
Se non vuoi usare la directory /misc né il file 'auto.misc', crea un nuovo file chiamato 'auto.mount' e aggiungi gli stessi parametri con la sintassi corrispondente, come nell'esempio seguente:
# vi /etc/auto.mount
Aggiungi la riga:
/mount_point -fstype=nfs,rw NFS.example.net:/export_name
NOTA: assicurati di aver modificato il file '/etc/auto.master' cambiando il file di mappa con quello desiderato.
4. Avvia il servizio 'autofs':
# service autofs start Starting automount: [ OK ]
5. Esegui il comando 'mount' per verificare che la tua condivisione NFS sia ora montata:
# mount NFS_IP_Address:/export on /mount_point type nfs (rw,vers=4,addr=NFS_IP_Address,clientaddr=local_IP_Address)
Suggerimento: con autofs il mount point viene popolato solo quando vi si accede: per questo nel listato di 'mount' potrebbe non comparire finché non lo usi. Accedi alla directory e poi verifica di nuovo.