Fstab – Automount SMB Fails to Root

cifsfstabrootsmb

I'm trying to automount some drives with smb with fstab entries as such.

# auto mount hda shares
//hda/DeannasDocs /home/deanna/DeannasServerDocs cifs user=deanna,pasword=** 0 0
//hda/Music       /home/deanna/ServerMusic        cifs user=deanna,pasword=** 0 0
//hda/Pictures    /home/deanna/ServerPhotos      cifs user=deanna,pasword=** 0 0

if I click on one of these drives I get an error "only root can mount"

If I manually mount with

sudo mount -a

I'm prompted for a password and they mount just fine. What the heck is going on here?

Answer: Of course it was something stupid.

I copied the syntax for the mount from offline and it has "pasword" instead of "password". It stood out initially but I thought it was just a Unix foible.

Best Answer

As a default, only root is allowed to mount / unmount volumes. You have to allow for other users with the "user" or "users" mount option, for example:

//192.168.1.100/Daten /home/otto/Daten cifs noauto,users,credentials=/home/otto/.smbcredentials  0 0

Where the .smbcredentials file contains username and password:

username=otto
password=wakeuplimeyfish

The noauto option means that the system will not mount the share automatically.

Of course, you do not need all of that to mount a Windows share as a regular user. Just open a file manager window and go to Browse Network -> Windows Network, select the share you want to mount, type the password etc. Or give the location (menu go -> location): smb://Fileserver/share, type in your domain / password etc.

Or use gvfs directly from command line:

gvfs-mount 'smb://user@fileserver/share'