AutoFS : montage et démontage de partages
You already installed Linux on your networked desktop PC and now you want to work with files stored on some other PCs in your network. This is where autofs comes into play. This tutorial shows how to configure autofs to use CIFS to access Windows or Samba shares from Linux Desktop PCs. It also includes a tailored configuration file.
If autofs Version 4.0 or newer is already installed, you should find thoses files :
on your system. Otherwise start the package manager of your distribution (e.g. YaST on SuSE, synaptic on Debian or Ubuntu, ...) and install it. When you are at it, also install the Samba client package (look for smbclient), because we will also need this.
Just do :
apt-get install autofs
For NFS, it's not very hard, just be sure it works fine when you mount it manually. You also need to install portmap :
apt-get install portmap
Now edit for example the auto.master file, and add a nfs file line :
/mnt /etc/auto.nfs --timeout=600
This mean it will be mounted in /mnt and will be automatically umounted after 10 min. Now edit your new file :
* -fstype=nfs,rw 192.168.0.187:/home
With some virtualized systems like OpenVZ, you'll need to add 'nolock' option in addition of fstype options :
* -fstype=nfs,rw,nolock 192.168.0.187:/home
If autofs is already installed, it is probably still not configured and not working. Assuming your Linux Distribution contains a Linux 2.6.x kernel I recommend to use the common internet file system (cifs) module to access files on the network. You also nee smbfs to be isntalled :
apt-get install smbfs cifs-utils
Please store the following file as
on your computer. You need root (or sudo) to have the permissions to do this:
share -fstype=cifs,rw,noperm,credentials=/etc/auto.cred ://server/share
This file must be executable to work (chmod 755) !
Just create a /etc/auto.cred file where credentials will be added. Then add those 2 lines :
change the permissions :
chmod 755 /etc/auto.cifs chmod a-x /etc/auto.cifs chmod 600 /etc/auto.cred
Restart service :
First we need to install sshfs :
apt-get install sshfs fuse
126.96.36.199 Key exchange
You first need to do key exchange from the root user on remote host.
188.8.131.52 Autofs configuration
Now edit the master file and add this line :
/mnt/remote_server /etc/auto.sshfs --timeout=360,--ghost
Now add this and adapt it for your needs :
myfolder -fstype=fuse,port=22,rw,allow_other :sshfs\#login@remote_host\:/the/share
- myfolder : folder will be accessible in /mnt/remote_server/myfolder
- login : type your ssh login
- /the/share : set the remote share
Do not forget to create the folder on your client machine.
Now reload autofs :
Now access to /mnt/remote_server/myfolder it will be automatically mounted.
You'll need to install this package :
aptitude install curlftpfs
Then add this line in /etc/auto.master :
/mnt/autofs /etc/auto.ftp --timeout=600
Now we need to create this file and add a line like that (replace with your informations) :
backups_ftp -fstype=fuse,allow_other,user=user:password :curlftpfs\server
3.5 Create a mountpoint per home user
To create a home mountpoint per connected user, you have to configure (NFS for example) like this :
* -fstype=nfs,rw 192.168.0.187:/home/&
& : correspond to each users
Use the command
ls -als /cifs/FILESERVERNAME/SHARENAME
mount.cifs //server/share /test -o username=login,password=pass
to check, if it works. If not, consult the system logfiles (usually /var/log/messages or /var/log/syslog) for messages.
5.1 My NFS connection is very slow
I can see this kind of of things in the syslogs :
... Jun 6 16:26:40 debusertest kernel: portmap: server localhost not responding, timed out Jun 6 16:26:40 debusertest kernel: RPC: failed to contact portmap (errno -5).
You just need to install the portmap package :-)
5.2 I encounter NFS delay problem
If you have this kind of problem :
Jul 8 15:50:39 deb-devtest2 automount: mount(nfs): mkdir_path /mnt/share/drive failed: No such file or directory Jul 8 15:50:39 deb-devtest2 automount: failed to mount /mnt/share/drive
Grow your auto.nfs file, option timeo :
drive -fstype=nfs,rw,rsize=8192,wsize=8192,timeo=60,intr server:/700G/share/drive
5.3 My CIFS doesn't want to mount
You may have a problem while automount a cifs share getting this errors in the logs :
Dec 27 11:36:07 pmavro-laptop automount: lookup(program): lookup for backups failed Dec 27 11:36:07 pmavro-laptop automount: failed to mount /mnt/backups/backups
As it's recommanded on this documentation, auto.cifs needs execute rights. But depending of the version of autofs you use, you may need to pull off those rights :
chmod a-x /etc/auto.cifs
Then restart autofs daemon.
It is possible to show wished volumes that are not mounted, this is easier to know which ones are available. Do to do it, simple add '--ghost' on a line on auto.master. Example :
[...] /mnt/mount1 /etc/auto.sshfs --timeout=720,--ghost /mnt/mount2 /etc/auto.cifs --timeout=720,--ghost