| « HOWTO:Set up NFS sharing | HOWTO Sort out kvm » |
I'm assuming you have Samba/Cifs already setup. If not there are loads of HOWTOs out there and this one is getting way too long already.
Setting up the shares is really really simple. The default install of autofs supplies a script /etc/auto.smb This is really good, although I have modified it slightly to get it to work the way I wanted. I do not want to automatically mount the hidden samba shares. Those that end with a '$'. I also added an extra check for a default credentials file when a specific server file does not exist.
Get my updated version here and save it as /etc/auto.smb, but backup your original file first. Just to save confusion remove the executable flags from the file too.
You can test this file is working simply by running it from the command line. I'm using a VMware machine that is running Windows 2K and is called imaginatively vmwin2ksamba. It has four shares, The entire C: and E: drives along with the downloads and Temp directories.
The script actually creates on the fly, the second and third parameters for a map file in multimap mode. See the autofs(5) man page for a very brief explanation of multimap mode.
To use /etc/auto.smb add a line to the /etc/auto.master and then restart the autofs daemon and try it out. I also add the nonstrict option to the map line, without it if any one of the connections or shares is wrong or you do not have permission then the whole thing breaks. Also I have a user samba who's gid=1001 and uid=1001. This user cannot run a login shell and is therefore a little more secure. See the Samba docs, they explain it much better than I do.
You can now look at the directory winshare/vmwin2ksamba and see all the available shares.
You may have to setup a credentials file to get access to all the shares on your network. The credentials file is from the default file /etc/auto.smb.<windows host > or with my modified version you can use a fall back file /etc/auto.smb.credentials. The file format is one key = value pair per line as in the following. I don't use the domain value and it still works ok.