Posts Tagged fstab mount windows share

Mount Samba/Windows/CIFS Share with User Read/Write Permissions

Mounting a Windows/SMB/CIFS share can be accomplished in many different ways. The way that I do it works best for me, and I'm presenting it here for anyone who wants to take advantage of the info.

I have a NAS device with Windows shares on IP 192.168.1.90 on my LAN. One of the shares is called "Docs" which I use for important documents. First I create a directory to mount the share to on my local machine. I put this in my /media directory.

1
sudo mkdir /media/Docs

Note that I'm using Debian Wheezy as my distro, but all of this should work in any distro.

Next I add a line to my /etc/fstab file. It can go at the bottom of the file. So, open /etc/fstab in your favorite editor. I'm using vim.

1
sudo vim /etc/fstab

The line I add for the share is:

1
\\192.168.1.90\Docs   /media/Docs cifs username=myuser,password=mypassword,uid=myuser,gid=users,auto 0 0

I set "myuser" to my actual local username. The reason I'm setting the uid in this line is because I want to specify that my user will be the owner of the mounted share (giving me read and write), and I'm setting the gid to users because I want all other users on the local machine to have read access to the mount.

After saving the file, I can sudo mount /media/Docs and I'll have my mount available for my user. When the system reboots, the mount will automatically occur. So my user will have access to the mount directly after boot.

An optional, more secure way to do this is to put your username and password in a file somewhere (perhaps your home directory) and replace the "username=myuser,password=mypassword" part of the mount line with "credentials=/path/to/file". This will help keep your passwords safe. Also note that these credentials aren't your local user credentials necessarily. They can be the same, if you set your local user up with the same creds as the share, but these credentials should be the user information that gets you access to the share.

»crosslinked«

, , , ,

No Comments