How do I mount Samba share as non-root user

Solution 1:

A very nice tool to easily mount your samba shares in your home folder is SMBNetFS. With this tool you can access your samba shares by nearly all applications simply through a mount point in your home.

How to use SMBnetFS:

  • Install the package through your package manager
  • cp /etc/smbnetfs.conf ~/.smb/smbnetfs.conf copy standard configuration
  • cp /etc/samba/smb.conf ~/.smb/smb.conf copy samba configuration
  • mkdir ~/sambashare or any other name for the mount point
  • smbnetfs ~/sambashare mount the shares to the mountpoint

Unfortunately there is only little documentation available. See man smbnetfs for options and go through the FAQ file in /usr/share/doc/smbnetfs.

Solution 2:

When using gnome, you can simply type in the smb:// url into Nautilus. Normally gvfs-fuse and other gvfs packages should be installed, so that you can mount samba directly with the file browser. Additionally you should find all mounted stuff in your ~/.gvfs folder. This even works with other protocols and compressed files etc.

gvfs-mount smb://user@server/storage

I've tested it with eclipse and other tools and it works. gvfs-fuse must be installed.

Solution 3:

man mount will help you determine what options you want. If the windows system will always be available. You can just add the mount to the /etc/fstab and it will be mounted. You can allow the user to mount and unmount the partition as required using the options user,noauto. To allow others to unmount it change user to users.

Autofs also supports on demand mounts using samba. The incantation depends on which directories you want mounted when. I've run it successfully in a development environment.

EDIT: If you need to do this for a lot of users, I suggest using autofs to do the mounting. This does not require changes to fstab. Obtaining credentials for the various users may be a problem. I use a directory structure in the form /net/$HOST/$USER for my mounts. Autofs is configured for the /net/$HOST portion of the mount and automatically mounts the directories under it as needed.

Particular mounting approaches depend on your needs. I have had cases where users needed their Desktop directory mounted on the server, although typical mounts are server based.

For large organization with lots of user it may make sense to move the directories to a Linux server and use Samba to share the files to Windows users. I haven't tried the reverse, but it may be possible.