I set up a SAMBA share on my CentOS server so that I could easily transfer files back and forth to other computers. I set up an auto mount on my laptop so that it would only attempt to mount the share when I need it. Took a few tries to get the syntax correct, but I basically followed this guide from the CentOS wiki.
Added this line to the /etc/auto.master file:
/mnt /etc/auto.centos01_ryan
Created the file /etc/auto.centos01_ryan and added this line to it:
centos01 -fstype=cifs,rw,noperm,user=ryan,pass=xxxxx ://centos01/ryan
The line in auto.master says that the mount will be created in the /mnt directory and will reference the auto.centos01_ryan file for details. The auto.centos01_ryan file defines the options of the mount. The first part “centos01” creates the actual mount point of centos01 in the /mnt directory. The next section are the mount options, just as they would be in /etc/fstab and finally the last section defines where to find the share. The CIFS/SAMBA share would normally just be //centos01/, but in the autofs definition file, the share cannot begin with a / or so it must be prefaced with a colon.
After setting up the options, restart autofs (/etc/init.d/autofs reload) and test that the share will mount. An ‘ls /mnt’ shows that the mount point has not yet been created, but issuing ‘/mnt/centos01’ mounts the share and it is now accessible and will show up until the mount times out. You can see automount settings by issuing ‘/etc/init.d/autofs status’ and you will get output similar to this:
ryan@ryan-laptop:~$ /etc/init.d/autofs status
Configured Mount Points:
————————
/usr/sbin/automount –timeout=300 /mnt file /etc/auto.centos01_ryanActive Mount Points:
——————–
/usr/sbin/automount –pid-file=/var/run/autofs/_mnt.pid –timeout=300 /mnt file /etc/auto.centos01_ryan