Mounting Windows Fileshares Properly in Ubuntu 12.04 LTS

I know, I know this has been documented to death on millions of Linux noob friendly sites but I got fed up of my memory not remembering this once every blue moon in the event when I have a new system installed and/or needed to handcode this in. Google is awash with duff advice other peoples’ favourite ways of doing things in Linux that I decided to write it down properly somewhere!

Ubuntu 12.04 has a great easy-to-use local network mounting method which lets you browse network shares through its native file browser but it doesn’t share all its connection details with other applications at a ‘proper’ mountpoint.

The solution as done with Ubuntu 12.04 LTS:

All this can be EASILY done by the terminal. Noobs, don’t be scared!
As space is tight on this page, each command is on ONE LINE unless separated by a blank line.

At a terminal run:
sudo mkdir /media/localmountnameThis creates the local mountpoint where your network share will be located on your local machine.

Open a text editor to edit your /etc/fstab file. If you need a hand doing this, run this from the terminal:
gksudo gedit /etc/fstab

Then add a new last line to the file: (you will need to adjust the details to match your network details)
//192.168.x.x/remotesharename /media/localmountname cifs credentials=/home/localusername/.smbcredentials,uid=shareuser,gid=sharegroup, file_mode=0777,dir_mode=07‌​77 0 0To translate://path/to/remotefileshare /path/to/localmountname CommonInternetFileSystem credentials=/file/containing/share/login/details, uid=InTheFile, gid=InTheFile, Read&WriteFiles, Read&WriteDirectories 0 0The last 0 0 means that the path is not backed up by ‘dump’ and is not checked when doing an fsck disk check.

Once you’ve done this, we’re going to create a file in your local user’s home folder containing the authentication details required to connect to your fileshare.
Create the .smbcredentials file in your home directory:sudo gedit ~/.smbcredentials

Populate the file with the following details, specific to your file share:

Save and close the file and set it’s filepermissions to that it is only read/writable by your local user.
chmod 0600 ~/.smbcredentials

Finally, mount the fileshare by calling to mount all drives & paths in our newly edited fstabsudo mount -a

You should all be done and ready to go. For further explantion on how the fstab works read up on it here.
Thanks to the folks in this forum thread upon which this guide was based.

Leave a Reply

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