I strongly recommend that you use Autofs to mount your Windows shares. This has many advantages over smbclient or adding cifs mounts to your fstab. Autofs is tolerant of reboots, disconnects when idle, reconnects on demand automatically, and is completely transparent at the user level. Give it a shot.
Here's an example setup.
# bunch of comments
/cifs auto.cifs --ghost
mntpoint -fstype=cifs,username=winuser,password=winpass,file_mode=0666,dir_mode=0777 ://winpc/share
When you restart the
autofs service, you'll have a new directory,
/cifs. You don't have to create it. The
autofs creates it, or destroys and then creates if already existing. (So don't try to make your autofs root
/media in your
Normally, when you
ls /cifs, it would appear empty. Navigating to
/cifs/mntpoint would trigger the automount and make the missing mount appear. However, the
--ghost option makes the mountpoints stay visible, even when not mounted.
Alternatively, you could have this as the contents of /etc/auto.cifs:
* -fstype=cifs,username=winuser,password=winpass,file_mode=0666,dir_mode=0777 ://winpc/&
This wildcard notation makes every share from
winpc automountable by navigating to
/cifs/sharename without having to define each share explicitly in
auto.cifs. This gives you the flexibility of creating and destroying shares on your Windows machine at will without having to change anything on your Linux box.
It makes the
--ghost option useless, though, so
ls /cifs would still appear empty when the cifs mounts haven't been triggered. You'd either have to remember the share names or create symlinks with
ln -s /cifs/sharename ~/sharename
Notice that in both examples of auto.cifs the
dir_mode options. Those are the permissions applied to files and folders of cifs-mounted resources. As they are, they grant read+write permission to everyone. If you wish to dial in the security a little, then:
create a group called "net" on your workstation:
add accounts to that group:
usermod -a -G net username
in auto.cifs add
in auto.cifs change
Also, if you're going to be storing your network share username and password in auto.cifs don't forget to
chmod 600 /etc/auto.cifs to prevent non-root from reading it.