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:

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:

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:

      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) ;-)

      Cheers!

Leave a Reply

Your email address will not be published.