Distroname and release: Ubuntu
Autofs on Ubuntuautofs can be used to automount cifs mounts (and others), when ever its accessed.
There is one major caveat . Password is stored Unencrypted on the harddrive! BAD! If you can live with this, then go ahead.
Start by installing autofs
apt-get install autofs cifs-utilsCreate the auto master, include directory.
sudo mkdir /etc/auto.master.dCreate an new autofs file which will be loaded by autofs.
Notice that first part is the "initial" mount point, which will be followed by the share name. (/mnt/cifs/sharename).
IMPORTANT mount point must NOT end with /
/etc/auto.master.d/cifs.autofs /mnt/cifs /etc/autofs.cifsCreate the mount file for autofs.
MYMOUNT is the autofs name, which we then can access by "/mnt/cifs/MYMOUNT/"
Note: #vers=2.0 might not be needed.
But if you get an error with "automount: >> mount error(112): Host is down", its most likely so.
This error might only show with debug enabled!
/etc/autofs.cifs MYMOUNT -fstype=cifs,rw,credentials=/home/user/.cifscredentials,file_mode=0777,dir_mode=0777,vers=2.0 ://SERVERNAME/PATH/To/FolderCreate an new file with username and password.
/home/user/.cifscredentials username=user password=secretpassSet correct permissions in this file, so only your user can read it.
chmod 400 /home/user/.cifscredentialsrestart autofs
/etc/init.d/autofs restartNow you should be able to view the content by going to /mnt/cifs/MYMOUNT/.
Remember, we set these "paths" previously!
It's likely it will not autocomplete for the MYMOUNT folder, but it should show up, if you just type it manually.
ls -l /mnt/cifs/MYMOUNT/If it aint working, start with debug