Ubuntu / Nas

FTP Server, File Server, DDNS, SAMBA, AFP, NFS
Post Reply
xolle
First post
Posts: 1
Joined: Tue Apr 22, 2014 9:10 am
Location: Denmark

Ubuntu / Nas

Post by xolle »

Hello Qnap Forum ppl !

I just went from using Win 8 - and to using ubuntu.
Im trying to map the folders onto my network. So that I can see the folders on my Qnap ts-212
from Ubuntu 14.04. How do I do that ? Everything I try does not work.

The main goal - is that I want to be able to share content between those two - and when I get to that - I wanna setup so a few of the Ubuntu folders automatic backup onto my Qnap.

As fare as I can tell Samba is not the way about this right ?

Thank you for reading - please help me out if you know how!

Thomas.
User avatar
pwilson
Guru
Posts: 22533
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: Ubuntu / Nas

Post by pwilson »

xolle wrote:Hello Qnap Forum ppl !

I just went from using Win 8 - and to using ubuntu.
Im trying to map the folders onto my network. So that I can see the folders on my Qnap ts-212
from Ubuntu 14.04. How do I do that ? Everything I try does not work.

The main goal - is that I want to be able to share content between those two - and when I get to that - I wanna setup so a few of the Ubuntu folders automatic backup onto my Qnap.

As fare as I can tell Samba is not the way about this right ?

Thank you for reading - please help me out if you know how!

Thomas.
I use Samba with all my Linux devices. Works well.

I use SMB networking for all of my machines, including my Debian (Kali Linux) boxes. I simply created folders called: Multimedia, Public, Download, Web, and Homes in the /share folder of my Kali boxes. With these "mount-points" created on my Kali machines, I simply add the following lines to my /etc/fstab file on each of my Kali boxes. (My NAS is named "nasty2").

Code: Select all

//nasty2/Multimedia     /share/Multimedia   cifs  defaults,rw,credentials=/etc/nas-credentials,dir_mode=0777,file_mode=0777
//nasty2/Public         /share/Public       cifs  defaults,rw,credentials=/etc/nas-credentials,dir_mode=0777,file_mode=0777
//nasty2/Download       /share/Download     cifs  defaults,rw,credentials=/etc/nas-credentials,dir_mode=0777,file_mode=0777
//nasty2/Web            /share/Web          cifs  defaults,rw,credentials=/etc/nas-credentials,dir_mode=0775,file_mode=0755
With this in place I can access all my NAS files in "/share" on my NAS, and "/share" on all my Kali boxes too. This gives the added advantage of allowing me to use MPlayer etc to watch all my movies etc on my Kali boxes. (MPlayer doesn't like loading SMB paths, but it is quite happy to load content in "/share/Multimedia" on my Kali boxes). It also allows me to load XBMC on my Kali boxes that are directly connected to the televisions within my home.

I never have to fight to get my NAS shares "mounted" as they are all pre-mounted before I even login to my Kali boxes. (I use a credentials file for my authentication, so I can store my /etc/nas-credentials file with 700 permissions, thereby protecting my "password" from prying eyes). This makes it easy to work with my NAS. Even my VM's can access my NAS shares this way.

/etc/nas-credentials:

Code: Select all

username=pwilson
password=BcMZI6BRcCQy8g
:!: Secure the "credentials" file:

Code: Select all

chmod 700 /etc/nas-credentials
This allows me to avoid all the challenges of getting NFS working on my NAS and Linux boxes, and simplifies my "file permissions" as I only have a single protocol to worry about. QNAP's NFS implementation leads a lot to be desired, by using SMB exclusively, I can completely avoid NFS on my network. This also saves RAM on both my NAS and my Kali boxes, because I can "disable" NFS, thereby freeing up some RAM.

As an "administrator" you have probably created the same "username" on all your machines, regardless of underlying OS. (This is a good practice), What you may not have done, is ensure that that your "username" has the same "UID" on all of your machines. If you take the trouble to ensure that you are using the same UID's on all your machines, this will make it far easier to mount shares between machines.

From my NAS:

Code: Select all

grep pwilson /etc/passwd
pwilson:x:1001:0:Linux User,,Patrick Wilson,:/share/homes/pwilson:/bin/sh


From my Kali box:

Code: Select all

grep pwilson /etc/passwd
pwilson:x:1001:1001:Patrick Wilson,,,:/home/pwilson:/bin/bash
Bringing your UID's into sync between machines is not absolutely necessary, (and can cause major issues if not done properly), so you might want to skip this part. If you change the UID of your username on your Debian 7.4 machine(s) you will loose access to all your files until you change ownership on them to match the new UID. If you aren't comfortable doing this, please avoid this step. (I do not want to be held responsible for issues introduced on your Debian machine).

I hope my musings in this message assist you in not only mounting your NAS shares on your Ubuntu machine, but that it also helps you do so securely. It is a very very bad idea to store passwords inside your /etc/fstab file. Please don't do it. Use the "credentials" option so that you don't have to expose them.

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.
watterman
Starting out
Posts: 23
Joined: Sat Mar 20, 2010 6:41 am

Re: Ubuntu / Nas

Post by watterman »

Hello,

I am trying to accomplish the same thing (mount NAS shares on Ubuntu using samba). I have this in my ubuntu /etc/fstab:

Code: Select all

//nas/Documents /mnt/Documents	cifs	defaults,uid=1000,gid=1000,credentials=/etc/nas-credentials
//nas/Qmultimedia /mnt/Qmultimedia cifs	defaults,rw,credentials=/etc/nas-credentials,dir_mode=0777,file_mode=0777
The arguments for each share are different due to my experimentation, but my goal is the same - to mount a NAS share in Linux with read/write permissions.
The uid and gid of 1000 came from the Ubuntu user "adrian". I have the same user name on the QNAP TS-219P+ but the uid and gid are different.

The problem I am having is that many programs complain about not being able to write to files on these shares, even though I can read and write any text file manually via a text editor. It is like the programs are only getting read permissions. Could this be as a result of the different uid/gid for the user "adrian"?

If not, what else could it be?

And another question for bonus points - why is it necessary to use samba to share files between two Linux devices? Wouldn't NFS be more native?

Thanks.
User avatar
pwilson
Guru
Posts: 22533
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: Ubuntu / Nas

Post by pwilson »

watterman wrote:Hello,

I am trying to accomplish the same thing (mount NAS shares on Ubuntu using samba). I have this in my ubuntu /etc/fstab:

Code: Select all

//nas/Documents /mnt/Documents	cifs	defaults,uid=1000,gid=1000,credentials=/etc/nas-credentials
//nas/Qmultimedia /mnt/Qmultimedia cifs	defaults,rw,credentials=/etc/nas-credentials,dir_mode=0777,file_mode=0777
No "rw" on /mnt/Documents????


watterman wrote:The arguments for each share are different due to my experimentation, but my goal is the same - to mount a NAS share in Linux with read/write permissions.
The uid and gid of 1000 came from the Ubuntu user "adrian". I have the same user name on the QNAP TS-219P+ but the uid and gid are different.

The problem I am having is that many programs complain about not being able to write to files on these shares, even though I can read and write any text file manually via a text editor. It is like the programs are only getting read permissions. Could this be as a result of the different uid/gid for the user "adrian"?
Of course they need to be the same. Look at my last message. My UID is 1001 on both devices.
watterman wrote:If not, what else could it be?

And another question for bonus points - why is it necessary to use samba to share files between two Linux devices? Wouldn't NFS be more native?

Thanks.
NFS is straight off the Ark, it is difficult to manage. Samba has been around for over 20 years. It's proven technology, and for ease of management. I use SMB Shares between all devices. I mount my SMB NAS shares on Linux, Android, and Windows. One protocol. Easy to look after. Even Apple has finally seen the light, SMB protocol is part of every major operating system.

But mostly because it works. I gave up on NFS in 1992. I've been using Samba ever since.

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.
watterman
Starting out
Posts: 23
Joined: Sat Mar 20, 2010 6:41 am

Re: Ubuntu / Nas

Post by watterman »

Thanks for your reply.
No "rw" on /mnt/Documents????
the "defaults" option includes "rw"
Of course they need to be the same. Look at my last message. My UID is 1001 on both devices.
OK. I'll have to apply that and give it another go. That's a big task though...
NFS is straight off the Ark, it is difficult to manage. Samba has been around for over 20 years. It's proven technology, and for ease of management. I use SMB Shares between all devices. I mount my SMB NAS shares on Linux, Android, and Windows. One protocol. Easy to look after. Even Apple has finally seen the light, SMB protocol is part of every major operating system. But mostly because it works.
Fair enough... although the jury is still out (at least for me) on that last part... :?
watterman
Starting out
Posts: 23
Joined: Sat Mar 20, 2010 6:41 am

Re: Ubuntu / Nas

Post by watterman »

Hello again...
Just thought I'd share my experiences for the benefit of others who might be following this thread.

As it turns out, the problems I had were not related to permissions or users at all. The "problem" programs are using sqlite. The locking problem with sqlite on samba shares is well documented (google it).

A work around is of course NFS. I found that to work a treat, many swear by it and it has better performance in a linux only environment.
However, if samba/cifs is a must, use the "nobrl" (no bit-range locking) option when mounting the share, i.e.

from a shell:

Code: Select all

mount -t cifs //nas/Documents /mnt/documents -o defaults,credentials=/etc/nascredentials,nobrl
or in your /etc/fstab:

Code: Select all

//nas/Documents /mnt/documents cifs defaults,credentials=/etc/nascredentials,nobrl
Hope this helps someone.
regards,
Adrian (watterman)
Post Reply

Return to “File Sharing”