Mount windows Shared folder in Ubuntu

This is not a post is just a reminder of how you can mount a windows shared folder permanently in Ubuntu.

First of all you must install CIFS support in Ubuntu.

sudo apt-get install cifs-utils

After this we have to create a folder in media where we mount the shared resource

sudo mkdir /media/whatyouwant

Then we’ll edit file fstab

sudo vi /etc/fstab

Add this line

//servername/sharename /media/whatyouwant cifs username=yourWindowsUsername,password=yourWindowsPassword,iocharset=utf8,sec=ntlm  0  0

Take care with spaces in dhared folder names

“If there is any space in the server path, you need to replace it by \040, for example //servername/My\040Documents”

Test with this

sudo mount -a

This is a god choice if you are the only one who can login to this server, but it isn’t if the are other users, because fstab is readable for everyone and they can read the password. For this reason I recomend to use a password file.

Create a file in your user home folder

sudo vi ~/.smbcredentials

Add following lines

username=YourUsername
password=YourPassword

Change permissions

chmod 600 ~/.smbcredentials

The edit file fstab

//servername/sharename /media/whatyouwant cifs credentials=/home/ubuntuusername/.smbcredentials,iocharset=utf8,sec=ntlm 0 0

Test with

sudo mount -a

Source: Ubuntu Wiki

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.