How to permanently mount a SAMBA drive under Linux

November 11th, 2011 Matt

A while back, I bought a QNAP NAS drive for backing up my server and other machines which are attached to the network.  Having created a number of shared folders on the NAS, I had shortcuts to them available to me via SAMBA, but I wanted to configure my desktop machine so that the folders were permanently mounted.

So, the first step was to make sure that SMBFS was installed and up to date:

sudo apt-get install smbfs

Once the installation was complete, rather than store the connection details in plain sight, I wrote a text file which would contain the details

sudo gedit .nascredentials

The text file includes the user name and password to connect to the NAS (which are different from my Linux username and password):

username=mynasuser
password=mynaspassword

To make sure that the file was then restricted, I changed the access permissions for the credentials file so that only root user could read it

sudo chmod 600 .nascredentials

The next step was to create a mount point folder, which was accessible to any user on the system

sudo mkdir /media/nas

sudo chmod 777 /media/nas

After this, I edited the fstab file to include the mounting commands (note that the text should all be on one line, but I’ve had to include line breaks here for formatting reasons!)

sudo gedit /etc/fstab

//<NAS IP Address>/backups /media/nas cifs
  credentials=/home/myuser/.nascredentials,dir_mode=0777,
  file_mode=0777,umask=000,uid=myuser 0 0

This does rely on the NAS drive having a fixed IP address, and “backups” is the name of the samba share name.

Finally, rather than reboot, I only had to execute the following command to mount the new share

sudo mount -a

If the NAS is not switched on when the computer starts, then the drive won’t be mounted – if that happens, then I just need to run the last command to mount the folder again.

Posted in Non-Oracle | No Comments »

  • Pages

    • About Us
    • Services From WorkflowFAQ
    • Training
    • Workflow Book
    • Careers
    • Forum
    • Blog
  • Oracle 11i Workflow Certified Expert
    Oracle 11i System Administrator Certified Expert

  • Search


  • Blog

    You are currently browsing the WorkflowFAQ weblog archives for November, 2011.

    Archives

    • February 2012
    • January 2012
    • November 2011
    • October 2011
    • September 2011
    • August 2011
    • July 2011
    • June 2011
    • April 2011
    • February 2011
    • January 2011
    • December 2010
    • October 2010
    • September 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010
    • December 2009
    • October 2009
    • August 2009
    • July 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
  • Categories

    • General Computing (30)
    • Non-Oracle (18)
    • Oracle (78)
      • Functional (20)
      • Technical (69)
    • Personal (2)

  • Links

  • General Computing

    • Computing Magazine
    • Download.com
    • SourceForge.net
    • The Daily WTF
    • The Register
  • Non-Computing

    • BBC News
    • Burnley-based professional photography
    • Cuteable
    • My wife’s shop
  • Oracle Related

    • AppsDBA
    • Oracle
    • Oracle Apps Blog
    • Oracle Magazine Interactive
    • Oracle Support
    • Oracle Technology Network
    • Oracle UK
    • Oracle Workflow Forum on OTN
    • Oracle WTF
    • OraFAQ
    • Steven Chan
    • Steven Feuerstein


Copyright © 2012 TS Fifteen Ltd. All rights reserved.