my ideas in action
auto mount your NAS share
July 21, 2014Posted by on
I have discovered a better way on mounting the NAS shares .
Previously I was using /etc/fstab but this was not very convenient.
So I found “autofs”. It is taking care of automounting the CD/DVD/ external shares (NFS/CIFS, etc) based on the usage. I mean that when you click on the folder then it will mount it , but when not using the mount folder then at a predefined timeout time it will umount it . This is a good feature for me since I wanted to unmount automatically when I do not use that share.
So after installing the autofs ( from repository) then you have to configure two files.
First is /etc/auto.master. You should put here the timeout setting and the mount directory.
If you have more mounting paths you can put different timeout settings.
My example below:
+auto.master /mnt/nfsfreenas /etc/auto.misc --timeout 60 --ghost
The second file is /etc/auto.misc . This contain the mount settings ( somehow similar with /etc/fstab file)
My example file here:
file : /etc/auto.misc
bsddataset -fstype=nfs,soft,sync,rsize=6000,wsize=6000 192.168.1.20:/mnt/data1/bsdshare
So what I have here is a Freenas Unix share on 192.168.1.20 ( bsdshare) that is NFS type.
You can put in this file the CIFS/Samba also or sshfs or other shares. CD/DVD disks work also.
at the end , after updating this two files with your setup please restart the autofs service with
service autofs restart