Wednesday, July 30, 2014

Auto Mount SMB Share at Boot

I have an Asus RT-N66U Router and it has two USB ports, one of which I have a 1 TB Western Digital Hard Drive attached.  To access it from my Ubuntu 14.04 box I have to use the BROWSE NETWORK option in Nautilus.  This usually works just fine but I started using a Backup Program called BACK IN TIME which does scheduled backups and it needs the remote server share attached all the time.  What we need to do is make a SMB Network Share (MS Windows Share) Auto Mount on Boot.

It's a little harder to do than just installing a few programs but it's not too bad.  Here's how we do it: (Read the NOTES section before starting)

1.  Open a Terminal Window

2.  Install CIFS (this may already be installed, Mine was)
         sudo apt-get install cifs-utils

3.  Create the mount directory.
          sudo mkdir /media/NautilusName

4.  Open your /etc/fstab file with gedit so you can edit it.
          sudo gedit /etc/fstab

5.  Once gedit opens your fstab file add the following 2 line to the bottom of the file and then save it.
         # Mount Point for Network SMB Share
         //192.168.1.1/ServerShare  /media/NautilusName cifs  guest,uid=1000,iocharset=utf8  0  0

6.  After you add the entry to /etc/fstab type:
         sudo mount -a

This last command will (re)mount all entries listed in /etc/fstab.  Open Nautilus and if you see your NautilusName is listed under NETWORK.  If so your good to go just reboot your computer and your network share will automount.

NOTES

We are connecting to the remote SMB Share as a guest which indicates you don't need a password to access the share.  To learn how to mount password protected shares go here.

NautilusName can be replaced by any name you want and it is what will show up in Nautilus.

//192.168.1.1/ is the IP address of your server and should be changed.

ServerShare is the share name on your server, change it to match yours.


The lines you added to your FSTAB file explained:

uid=1000 makes the Linux user specified by the id the owner of the mounted share, allowing them to rename files.

iocharset=utf8 allows access to files with names in non-English languages. This doesn't work with devices or Windows machines that export their shares using ISO8895-15.
 
If there is any space in the server path, you need to replace it by \040, for example if your server path is  "//servername/My Documents" use this instead  //servername/My\040Documents


Here is an image of the lines I added to my FSTAB file.