NFS vs. SMB: A Crash Course on Network File Sharing

If you want to share files over a local network, you have two main solutions to choose from: NFS and SMB. Which option to choose depends in part on which operating systems you use, although there’s more to consider than that. Below, we offer you a primer on how the NFS and SMB file sharing protocols work and which use cases best align with each solution.

What is NFS?

Network File System, or NFS, is a protocol that defines how computers can share data over a network. Introduced in 1984, it is a tried-and-true solution that remains in widespread use today.

NFS uses a server-client architecture to make files accessible to multiple computers over a local network. On the server machine, admins write config files that specify which local directories on the server should be shareable over the network. Client computers can then mount the files over the network using the mount command (or by adding them to their /etc/fstab file, which will mount the directories automatically).

From the perspective of the client computer, a network-mounted directory shared via NFS looks and feels just like a local directory. Anything that you can do with a local file can also be done to a file in an NFS share.

Once a directory is shared over the network, the NFS daemons running on both the server and clients keep data in sync between all machines. In other words, if a file within a NFS-mounted directory changes on one computer, it will be changed on all other computers on the network that are connected to the NFS server.

Technically, NFS could be used to share data over non-local networks (i.e., the public Internet) as well, but it’s typically only used on local networks. Sharing files over the Internet would be difficult because NFS is not designed to handle complex routing configurations or perform network address translation. The fact that NFS is not encrypted by default also makes it a less than ideal solution for sharing files across the public Internet.

Historically, NFS has been very popular on Unix and Unix-like operating systems (a category that includes Linux). That is due largely to the facts that NFS was originally developed by Sun Microsystems, a major Unix vendor, and that the protocol has long been an open standard, making it easy for operating system developers across the open source world to implement NFS within their systems. Today, NFS runs on virtually every operating system in existence — including Windows, for which NFS server and client software is available.

What is SMB?

Short for Server Message Block, SMB is a protocol for sharing files and other resources (such as printers) over a local network.

SMB is also sometimes called CIFS, which stands for Common Internet File System. Technically speaking, CIFS is an implementation of SMB, so the terms don’t mean exactly the same thing. But in common usage the terms are often used interchangeably to refer to the SMB protocol and/or applications that use it.

SMB uses a server-client architecture that is similar to that of NFS: A computer that has files to share configures them to be available over the network, and client computers can then connect to them by entering the hostname of the computer (or its IP address) and the path to its SMB file share.

Unlike NFS, though, SMB doesn’t treat network-mounted directories as if they are local directories. There’s a stronger distinction between local files and network files under SMB.

Although IBM created the first version of SMB decades ago, Microsoft, which has long used SMB as the default file sharing protocol in Windows, has embraced and improved the protocol substantially since it was introduced.

Nonetheless, SMB support is available on Linux and other Unix-like systems via Samba, an open source implementation of the SMB protocol. With Samba, Linux computers can both host and share files (as well as printers) over a local network using the SMB protocol.

File sharing in hybrid environments

Because NFS is the default file sharing protocol in the open source world, and SMB is the default in the Windows ecosystem, the choice of which to use depends in part on which operating systems are running in your environment. If you’re a Linux-only shop, NFS is the obvious solution, while SMB is the best option for Windows-centric organizations.

NFS in hybrid environments

However, what if you manage a hybrid environment with both Linux and Windows PCs and servers? There are a few potential approaches you could take, each with advantages and drawbacks.

 One is to use NFS to share files between all computers. As noted above, NFS can run on Windows as well as Linux. Yet setting up NFS in Windows is complex, especially if you want to use a Windows machine as an NFS server. You have to manage Active Directory groups and users to allow NFS access. If you want to encrypt NFS connections, you’ll have to set that up separately on Windows, too.

NFS on Linux also requires some configuration, but it’s generally simpler. NFS expects your users and groups to be managed using the standard Unix approach — files like /etc/user and /etc/group — and some Linux distributions’ package managers can automatically install the encryption tools you’ll need for NFS at the same time that they install NFS itself.

Unless you only have a few Windows computers to manage, then, and they will be running only as clients rather than file servers, NFS may not be the best option in a hybrid environment.

SMB in hybrid environments

Compared to NFS, SMB is relatively easy to set up on both Windows and Linux machines. SMB support is enabled by default in most versions of Windows. You’ll need to install Samba manually in most cases on Linux, but it’s not hard to install and configure SMB support on most Linux distributions.

The major drawback of SMB in hybrid environments is the fact that, because Samba is an open source project, it doesn’t always provide perfect compatibility with Microsoft’s implementations of SMB. You may occasionally encounter bugs when trying to share files between Linux and Windows computers, and recently released features within SMB may not yet be supported by Samba.

These potential SMB compatibility issues are usually not show-stoppers, but they can be a problem if you require totally flawless file sharing on both Windows and Linux machines.

Third-party hybrid file sharing solutions

A third approach is to use a commercial file sharing solution, such as NetApp ONTAP. These platforms are designed specifically for sharing files in hybrid environments, and they support Windows and Linux equally well. You can run them locally or use a cloud-based service like Cloud Volumes ONTAP, which hosts files in the cloud and shares them with clients of all types.

This approach allows you to overcome the configuration and support challenges associated with the other two approaches. Of course, because solutions in this category are commercial, you’ll have to pay for them, whereas most NFS and SMB clients and servers are free to use.

The bottom line

NFS and SMB are both battle-tested solutions for sharing data over a network. Although NFS is easiest to use in Linux-based environments and SMB is simplest on Windows, both protocols can work on any mainstream operating system. Still, it’s important to think about potential configuration and compatibility challenges associated with both protocols, and evaluate whether a commercial file sharing platform may be a better choice.