How To: Mount a NAS in Linux (via CIFS)

Apparently CIFS is the new Samba, so to mount your NAS via CIFS instead of Samba, read this, then change the fstab line to:


i.e. For me it’s:

// /mnt/Share cifs credentials=/root/.credentials,rw,auto,uid=r3dux,gid=r3dux 0 0

You might notice reference to a .credentials file above. You need to create this!!

The format of the credentials file [you can call it anything & place it anywhere – just make sure you point to it in the fstab lines(s)] is:


So stick the above two lines in a file, substituting appropriately for the accounts and passwords on your NAS, then sudo chmod 600 it and remount the filesystem with sudo mount -a.

Job’s a good ‘un!

Update: Don’t forget – you’ll need to have samba, smbfs and cifs-utils installed for this to work! So go nuts with:

sudo apt-get install samba smbfs cifs-utils

3 thoughts on “How To: Mount a NAS in Linux (via CIFS)”

  1. Thanks, this post has saved me looking it up MANY times… props!

    By the way, changing the rw to r in the fstab line(s) does NOT mount in read only mode. Can touch/gedit/rm -i files just like it were a home directory. Do you know how to mount the points in read only mode?

    1. Haha, me too – and you’re welcome =D

      For the read-only it’s getting credentials from the NAS itself, so one way would be to create a user on the NAS which only has read-only access to the share.

      Or, I just got mine to mount read-only by using the line:

      //YOUR-NAS-IP/YOUR-SHARE /mnt/Share cifs credentials=/root/.credentials,iocharset=utf8,file_mode=0500,dir_mode=0500 0 0

      The only problem with mounting shares through fstab is that you have to umount the share for the machine to shutdown cleanly – I keep meaning to write a script to run on shutdown but then never get around to it! I just have a shell script that does it in one hit… You’re welcome to work it all out as a sysv script if you’d like (nudge, nudge) ;-)


Leave a Reply

Your email address will not be published.

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