21

I mounted a Windows share to my Ubuntu 11.10 system via adding the following line to the /etc/fstab:

//serveraddr/sharedfolder /mnt/foldername/ smbfs credentials=/home/myname/.smbpasswd 0 0

using the tutorial here.

But there's a problem with the permissions. The owner of the mount folder is root. I can not create any folders or files in the mounted point is I don't become the root. Even I can not change the ownership to my default user via

sudo chown -R myname .

I googled and saw that it might stem from the fact that Windows file formats (fat32/ntfs) can not save ownership. But when I connect to the same location via samba as

smb://serveraddr/sharedfolder

by providing my credentials, I have the privileges to write without being the root.

How can I make it to let me write to the mounted folder?

1 Answer 1

30

Don't use smbfs, the new protocol's name is cifs and its part of the package cifs-tools (install it if you did not already.

Instead use this line in your fstab

//server/share /mnt/mountname cifs username=server_user,password=user_password,iocharset=utf8,file_mode=0777,dir_mode=07‌​77 0 0

Where

server = your server that you are trying to access
share = mapped share on that server
/mnt/mountname = any folder that you created with sudo /mnt/<folder_name>
username = the name of the user on that server that can access the mount
password = the password for that user

After that you can test with sudo mount -a, if you dont get any faults you can safely reboot to find your shares mounted in /mnt/<folder_name>.

To use a credentials file instead of the username and password parameters on the fstab you can create a file with those 2 lines so that your username and password are not explicitly shown in the fstab

sudo nano /etc/cifspwd

Add these lines to the file

username=<username on server>
password=<password for that username>

Press ctrl+x keys and when asked press y to save the file.

Secure it with

sudo chmod 600 /etc/cifspwd

Use this line instead of the previous

//server/share /mnt/mountname cifs credentials=/etc/cifspwd,iocharset=utf8,file_mode=0777,dir_mode=07‌​77 0 0

After this it will be safe to reboot and you mount should be mounted and your details secured.

19
  • If this does not work please paste the output of cat ~/.smbpasswd. Oct 26, 2011 at 17:58
  • 1
    Added information for the credentials file, you can also use that method. Oct 26, 2011 at 19:45
  • 2
    I think it's worth noting that in Ubuntu 12.10, "mode" was not a valid parameter. Instead, I had to use "file_mode". Also, I'm not sure I entirely agree with general permissions of 0777. If you're mounting a private share just for yourself, I think something like "file_mode=0660,dir_mode=0770" would be more appropriate.
    – Avian00
    Mar 13, 2013 at 8:11
  • 1
    answering my own question: add uid=user_id,gid=group_id to the list of options into the fstab
    – Timofey
    Aug 7, 2015 at 23:34
  • 1
    These days, the package name for cifs seems to be cifs-utils. Feb 22, 2016 at 11:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .