Fork me on GitHub

auto.cifs

auto.cifs is a Perl script that dynamically produces automount maps for mounting CIFS shares (also called SMB shares and Windows shared drives) on demand with Samba on Linux. This means that you can do things like ls /cifs/myhost:myshare:user and you'll see the contents of \\myhost\myshare. In other words, this works a bit like Network Neighbourhood in Microsoft Windows. No manual mounting is needed.

Requirements

Perl, Samba, autofs, and a Linux kernel that has support for automounting compiled in. You probably have all of these things already.

Installation

  1. Place auto.cifs in /etc and make it executable with chmod a+x /etc/auto.cifs
  2. Add the line /cifs /etc/auto.cifs to /etc/auto.master
  3. Restart the automounter with /etc/rc.d/init.d/autofs restart (or whatever the equivalent is for your Linux distribution).

Configuration

If you only access shares that don't need a password, you can skip this step. Otherwise, you'll need to put a file called .auto.cifs in your home directory and do chmod go-rw ~/.auto.cifs to make sure others can't access it. This file is used to tell auto.cifs what password it should use to log on to a given share. If the file doesn't exist, or doesn't contain an entry for a given share, a guest login will be attepted instead. Edit the example file as necessary.

Usage

Just treat /cifs/host:share as an ordinary directory. It will magically pop into existence as soon as you try to use it. If it doesn't, you might want to check /var/log/messages for errors.

Note that if you specify a local username that isn't yours, it'll go ahead and mount the filesystem anyway if it can, but you won't be able to read from it.

Licence

auto.cifs is made available under the GNU GPL, version 2.

Source

Now on GitHub.

Last updated: 2012-05-11
Back to home