Autofs (Italiano)

From ArchWiki
Revision as of 16:23, 5 February 2011 by Maveloth (talk | contribs) (iniziata la traduzione)
Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Tango-preferences-desktop-locale.pngThis article or section needs to be translated.Tango-preferences-desktop-locale.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Autofs (Italiano)#)
Nota: Questo articolo è in fase di traduzione. Seguite per ora le istruzioni della versione inglese.


Questo documento evidenzia la procedura necessaria per configurare AutoFS, un pacchetto che permette l'automount di periferiche rimovibili o cartelle di rete quando inserite o accessibili.


  • Installare il pacchetto AutoFS:
# pacman -S autofs
# modprobe autofs4


AutoFS usa dei file template per la configurazione, questi file posso essere trovati in Template:Filename. Il template principale si chiama Template:Filename, che può fare riferimento ad uno o più template per determinate periferiche.

  • Aprire il file Template:Codeline con il proprio editor di testo preferito, conterrà qualcosa di simile a questo:


La prima parte di ogni riga determina la cartella dove verranno effettuati i mount delle periferiche, il secondo parametro indica il template da utilizzare. Il valore di default è Template:Filename, ma può essere cambiato con una qualsiasi cartella a piacimento. Per esempio:

/media/misc     /etc/autofs/auto.misc     --timeout=5 --ghost
/media/net      /etc/autofs/      --timeout=60 --ghost

I parametri opizionali Template:Codeline impostano dopo quanti secondi verrà effettuato l'umount delle cartelle. Il parametro Template:Codeline imposta la visualizzazione permanente dei mount delle periferiche configurati, invece di essere mostrati solo se inseriti o accessibili. Può essere utile se non è possibile ricordare i nomi delle periferiche rimovibili o delle condivisioni di rete.

Le cartelle indicate nel file devono esistere nel sistema e devono essere vuote, dato che il loro contenuto sarà cambiato dinamicamente al caricamento delle periferiche. Questa procedure comunque non sovrascrive di dati contenuti nelle cartelle, quindi se si effettua l'automount di una periferica su di una cartella attiva sarà possibile cambiarne il punto di mount nel file Template:Filename e riavviare AutoFS per poter accedere nuovamente al suo contenuto originale.

Note: Assicurarsi di lasciare una riga vuota alla fine dei ogni file template (premendo Template:Keypress dopo l'ultima parola del file). Se AutoFS non trova un EndOfFile(EOF) corretto, non sarà caricato correttamente.
automount: files
  • Quando la configurazione è terminata, avviare il demone AutoFS come utente root:
# /etc/rc.d/autofs start

Per avviare il demone durante il boot sarà necessario aggiungere Template:Codeline all'interno dell'array Template:Codeline nel file Template:Filename, ed il modulo Template:Codeline nell'array Template:Codeline sempre nel solito file.

Le periferiche verranno ora montate automaticamente quando accessibili, rimarranno montate fino a che l'accesso ad esse è garantito.

Removable media

  • Open /etc/autofs/auto.misc to add, remove or edit miscellaneous devices. For instance:
#kernel   -ro                              
#boot     -fstype=ext2                               :/dev/hda1
usbstick  -fstype=auto,async,nodev,nosuid,umask=000  :/dev/sdb1
cdrom     -fstype=iso9660,ro                         :/dev/cdrom
#floppy   -fstype=auto                               :/dev/fd0

If you have a CD/DVD combo-drive you can change the cdrom line with "-fstype=auto" to have the media type autodetected.

NFS Network mounts

AutoFS provides a new way of automatically discovering and mounting NFS-shares on remote servers (the AutoFS network template in /etc/autofs/ has been removed in autofs5). To enable automagic discovery and mounting of network shares from all accessible servers without any further configuration, you'll need to add the following to the /etc/autofs/auto.master file:

/net -hosts --timeout=60

Each host name needs to be resolveable, e.g. the name an IP address in /etc/hosts or via DNS and please make sure you have at least nfs-common installed and working.

For instance, if you have a remote server fileserver with an NFS share named /home/share, you can just access the share by typing:

# cd /net/fileserver/home/share
Note: Please note that ghosting, i.e. automatically creating directory placeholders before mounting shares is enabled by default, although AutoFS installation notes claim to remove that option from /etc/conf.d/autofs in order to start the AutoFS daemon.

The -hosts option uses a similar mechanism as the showmount command to detect remote shares. You can see the exported shares by typing:

# showmount <servername> -e 

Replacing <servername> with the name of your own server.


The Arch package does not provide any samba or cifs templates/scripts (23.07.2009), but the following should work for single shares:

add the following to /etc/autofs/auto.master

/media/[my_server] /etc/autofs/auto.[my_server]

and then create a file /etc/autofs/auto.[my_server]

[my_share] -fstype=cifs,[other_options] ://[my_server_ip]/[my_share]

FTP and SSH (with Fuse)

Remote FTP and SSH servers can be accessed seamlessly with AutoFS using Fuse, a virtual file system layer.

Remote FTP

First, install the curlftpfs package from the Community repository:

# pacman -S curlftpfs

Load the Fuse module:

# modprobe fuse

Add fuse to the modules array in /etc/rc.conf to load it on each system boot.

Next, add a new entry for FTP servers in /etc/autofs/auto.master:

/media/ftp        /etc/autofs/auto.ftp    --timeout=60 --ghost

Create the file /etc/autofs/auto.ftp and add a server using the ftp://myuser:mypassword@host:port/path format:

servername -fstype=curl,rw,allow_other,nodev,nonempty,noatime    :ftp\://myuser\:mypassword\@remoteserver

Note: Your passwords are plainly visible for anyone that can run df (only for mounted servers) or view the file /etc/autofs/auto.ftp. If you want slightly more security you can create the file ~root/.netrc and add the passwords there. Passwords are still plain text, but you can have mode 600, and df command will not show them (mounted or not). This method is also less sensitive to special characters (that else must be escaped) in the passwords. The format is:

machine remoteserver  
login myuser
password mypassword

The line in /etc/autofs/auto.ftp looks like this without user and password:

servername -fstype=curl,allow_other    :ftp\://remoteserver

Create the file /sbin/mount.curl with this code:

#! /bin/sh
curlftpfs $1 $2 -o $4,disable_eprt

Create the file /sbin/umount.curl with this code:

#! /bin/sh
fusermount -u $1

Set the permissions for both files:

# chmod 755 /sbin/mount.curl
# chmod 755 /sbin/umount.curl

After a restart your new FTP server should be accessible through /media/ftp/servername

Remote SSH

These are basic instructions to access a remote filesystem over SSH with AutoFS.

Note: The example below does not use an ssh-passphrase to simplify the installation procedure, please note that this may be a security risk in case your local system gets compromised.

Install the sshfs package from the Extra repository:

# pacman -S sshfs

Load the Fuse module:

# modprobe fuse

Add fuse to the modules array in /etc/rc.conf to load it on each system boot:

Install OpenSSH:

# pacman -S openssh

Generate an SSH keypair:

# ssh-keygen -t dsa

When the generator ask for a passphrase, just press enter. Using SSH keys without a passphrase is less secure, yet running AutoFS together with passphrases poses some additional difficulties which are not (yet) covered in this article.

Next, copy the public key to the remote SSH server:

# ssh-copy-id -i /home/username/.ssh/ username@remotehost

See that you can login to the remote server without entering a password:

# sudo ssh -i /home/username/.ssh/id_dsa username@remotehost
Note: The above command is needed to add the remote server to the root's list of known hosts. Alternatively, hosts can be added to /etc/ssh/ssh_known_hosts

Create a new entry for SSH servers in /etc/autofs/auto.master:

/media/ssh		/etc/autofs/auto.ssh	--timeout=60 --ghost

Create the file /etc/autofs/auto.ssh and add an SSH server:

servername     -fstype=fuse,rw,allow_other,IdentityFile=/home/username/.ssh/id_dsa :sshfs\#username@host\:/

After a restart your SSH server should be accessible through /media/ssh/servername

Troubleshooting and tweaks

This section contains a few solutions for common issues with AutoFS.

Using NIS

Version 5.0.5 of AutoFS has more advanced support for NIS. To use AutoFS together with NIS, add "yp:" in front of the template names in /etc/autofs/auto.master:

/home   yp:auto_home    --timeout=60 
/sbtn   yp:auto_sbtn    --timeout=60

On earlier versions of NIS (before 5.0.4), you should add "nis" to /etc/nsswitch.conf:

automount: files nis

Optional parameters

You can set parameters like timeout systemwide for all AutoFS media in /etc/conf.d/autofs:

  • Open the /etc/conf.d/autofs file and edit the daemonoptions line:
  • To enable logging (default is no logging at all), add --verbose to the daemonoptions line in /etc/conf.d/autofs, e.g.:
daemonoptions='--verbose --timeout=5'

After restarting the autofs daemon, verbose output is visible in /var/log/daemon.log.

Identify multiple devices

If you use multiple usb drives/sticks and want to easily tell them apart, you can use AutoFS to set up the mount points and udev to create distinct names for your usb drives. See Map Custom Device Entries with udev for instructions on setting up udev rules.

AutoFS permissions

If AutoFS isn't working for you, make sure that the permissions of the templates files are correct, otherwise AutoFS will not start. This may happen if you backed up your configuration files in a manner which did not preserve file modes. Here are what the modes should be on the configuration files:

  • 0644 - /etc/autofs/auto.master
  • 0644 - /etc/autofs/
  • 0644 - /etc/autofs/auto.misc
  • 0644 - /etc/conf.d/autofs

In general, scripts (like previous should have executable (chown a+x filename) bits set and lists of mounts shouldn't.

If you are getting errors in /var/log/daemon.log similar to this, you have a permissions problem:

May  7 19:44:16 peterix automount[15218]: lookup(program): lookup for petr failed
May  7 19:44:16 peterix automount[15218]: failed to mount /media/cifs/petr

External links and resources

Alternatives to AutoFS