autofs mounting WIndows Shares on CentOS 5

Create a directory for the mountpoint:

mkdir /mnt/mywinserver

Temporarily mount:

mount -t cifs //1.2.3.4/LogFiles /mnt/mywinserver -o username=jonny,password=letmein

For a more permanent mount  edit /etc/auto.master file add a line like:

/mnt/mywinserver /etc/auto.mywinservermount

Edit /etc/auto.mywinservermount and add the following:

LogFiles -fstype=cifs,user=jonny,password=letmein ://1.2.3.4/LogFiles

Protect the /etc/auto.mywinservermount file:

chmod 600 /etc/auto.mywinservermount

Access the mount to check it is working:

ls -al /mnt/mywinserver/LogFiles

Upon access the mount is auto-mounted. After about 60 seconds (/etc/sysconfig/autofs) of no access it is unmounted so basically the share is only mounted when it is needed.

Note: ls -al /mnt/mywinserver will not automount the mount specified in /etc/auto.mywinservermount – the directory will just be empty. However specifying ls -al /mnt/mediator/LogFiles will perform the automount and list the contents of the share.

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>