92

I am setting up a box to be a file server at the house. It will mainly be used to share music, pictures, movies with other linux boxes on the network, and one OS X machine. From what I have read NFS and samba would work in my situation, and as such I am not sure which to choose. What is important to me is the speed transfers between boxes and how difficult it is to setup.

Which would you recommend and why?

5 Answers 5

88

In a closed network (where you know every device), NFS is a fine choice. With a good network, throughput it disgustingly fast and at the same time less CPU intensive on the server. It's very simple to set up and you can toggle readonly on shares you don't need to be writeable.

I disagree with Anders. v4 can be just as simple as v3. It only gets complicated if you want to start layering on security through LDAP/gssd. It's capable of very complex and complete security mechanisms... But you don't need them. They're actually turned off by default.

sudo apt-get install nfs-kernel-server

Then edit /etc/exports to configure your shares. Here's a line from my live version that shares my music:

/media/ned/music        192.168.0.0/255.255.255.0(ro,sync,no_subtree_check)

This shares that path with anybody on 192.168.0.* in a readonly (notice the ro) way.

When you've finished editing, restart NFS:

sudo /etc/init.d/nfs-kernel-server restart

To connect a client, you need the NFS gubbins (not installed by default):

sudo apt-get install nfs-common

And then add a line to /etc/fstab

192.168.0.4:/media/ned/music  /media/music  nfs ro,hard,intr 0 0

This is actually the NVSv3 client still because I'm lazy but it's compatible in this scenario. 192.168.0.4 is the NFS server (my desktop in this case). And you'll need to make sure the mount path (/media/music here) exists.


For a Mac, follow this: http://www.techrepublic.com/blog/apple-in-the-enterprise/mounting-nfs-volumes-in-os-x/

It's much more simple than some older tutorials would have you believe.


It might look more complicated than it really is but it's solid, predictable and fast. Something you can't level against Samba... At least, in my experience.

5
  • Thanks for all the details. I think I am ready to give this a shot this weekend now. Oct 14, 2010 at 12:21
  • How do you get this to be persistent (to the client) on server reboot? I have a similar setup working fine (/etc/fstab set to mount, in my case, a NAS folder), but when the server reboots I'm repeatedly going through umount and mount -a gyrations in the terminal to get my mount back. Mostly fine for me (except for annoyances like Picasa wiping the local DB when the network photo folder is suddenly absent :(), but this drives my wife up the wall...
    – Russ
    Jan 20, 2011 at 4:00
  • @Russ Sounds like your network connection takes a long time to get started. Consider adding auto,_netdev to the options fragment so it looks something like: auto,_netdev,ro,hard,intr This should force the filesystem to wait for a network connection.
    – Oli
    Jan 20, 2011 at 9:35
  • 1
    Thanks for your explainations! Some more questions: why not using FTP? I heard that the UIDs have to be unique... That sounds really complicated for me. How does NFS deal with file permissions?
    – lumbric
    Dec 26, 2011 at 11:56
  • @lumbric Super late reply, sorry. FTP is transactional and as a result is really clunky and slow. It has a pretty good throughput but everything that matters in a filesystem for actual use (statting, listing, etc) is tedious. Permissions can be tailored, and users mapped with the various LDAP/gssd configurations but these are beyond my needs (and currently beyond my knowledge).
    – Oli
    Apr 16, 2013 at 11:04
18

I recently tested the connection via SMB and NFS to my Synology NAS station. For me the NFS connection works two times faster than the SMB connection. Especially if you have to deal with 100 GByte of photos and music files in 1000 directories you will love the speed of NFS.

0
6

I recently setup a local NFS server on Ubuntu 10.04 server, but my MacBook Pro (OS X 10.6.X) couldnt connect. For the Mac to be able to connect i had to add insecure to the /etc/exports.

My /etc/exports:

/mnt/sdcard *(rw,sync,no_subtree_check,insecure,all_squash)
0
6

Run real-world tests before you dedicate the next X years and Y TB to a particular protocol never realizing that there was a better option.

You'll find opinions all over of which one is faster with the Samba people claiming that they are on par with NFS. Depending on your needs, the best thing to do would be to set up a Samba share and NFS share and run various real-world read/write/CPU tests across the network. If you have similar needs as I do (Windows machines) you might be surprised to find out that Samba is 20% faster than NFS.

Go with the one that gives the best results in your setup and ignore what people say is the fastest.

0
6

NFS (version 3) will give higher performance and is quite easy to set up. The main problem is the complete lack of decent security.

NFS (version 4) gives security

Samba will probably be a bit slower but is easy to use, and will work with windows clients as well..

4
  • 20
    but is almost impossible to set up: Can you back that up with some evidence or is that just based on your subjective feeling?
    – lanoxx
    Nov 4, 2015 at 12:43
  • 4
    I never had an issue with v4, so what's the problem?
    – KingCrunch
    Mar 13, 2016 at 0:55
  • I didn't find NFSv4 any harder than NFSv3. Of course, that's without Kerberos.
    – MountainX
    Feb 12, 2018 at 7:15
  • As someone who recently was struggling trying to compare NFS and SMB I can tell they are both terrible. SMB is even worse in terms of configuration, because I spent more time with it and still have one problem left with permissions. That doesn't matter though because upon comparison turned SMB is slower than even NFS and SSHFS summed up.
    – Hi-Angel
    May 22, 2020 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .