Skip to content
Search

Network File System

lastmod 2026-02-09created 2015-07-2416 edits

Network File System (NFS) is a protocol developed by Sun Microsystems in 1984. It lets a user on a client computer access files over a network in a way similar to accessing directly attached storage. Like many other protocols, it is built on the ONC RPC system. Because Network File System is an open standard defined in RFCs, anyone can implement it.

Categories

About

NFS (Network File System), as the term says, means a network-based file system. It is a method that lets other Linux systems use shared files on a remote host locally. It has been widely used from NFS v2 through the current v4, and it is very convenient in that remote file systems can be shared easily.

However, as convenient as it is, its security vulnerabilities must also be considered, so unless it is dedicated NFS storage, it is best to share it as Read Only or so.

With NFS, a Linux Server can share directories with other Linux/operating system clients over the network. The NFS server exports the directory, and the NFS client mounts it. Today NFS mainly uses v3 and v4.

How to install

On ubuntu

## nfs 관련 설치된 패키지가 있는지 확인
dpkg -l | grep nfs

apt-get -y install nfs-kernel-server

On CentOS

## nfs 관련 설치된 패키지가 있는지 확인
rpm -qa | grep nfs

yum -y install nfs-utils

How to mount

See the showmount and mount commands.

# 마운트 포인트 확인
showmount -e 192.168.100.7

# 마운트 방법
sudo mount -t nfs 192.168.100.7:/AIC ./temp/

# NFSv4 사용
sudo mount -t nfs -o nfsvers=4 192.168.100.7:/AIC ./temp/

# 읽기/쓰기 권한 명시
sudo mount -t nfs -o rw,sync 192.168.100.7:/AIC ./temp/

NFS v3 (1995)

  • NFS version3 supports Async-style Writed mode
  • Supports 64bit File Size Offsets, so files larger than 2GB can be accessed
  • Supports TCP/UDP Port 2049, but on actual IP Networks it connects in a UDP-based Stateless manner
  • Reliability issues may occur due to UDP transport.

NFS v4 (2003)

  • NFS version4 does not need the rpcbind service, supports ACLs, and can operate in a Statuful manner.
  • Supported on all RHEL/CentOS 6 and later, and NFS v4 is configured as the default for default mounting.
  • Uses TCP, so reliability can be guaranteed.
  • Supports TCP Port 2049
  • NFS v4.1 released in 2010; NFS v4.2 is currently the latest

NFS RPC processes and key services

  • rpc.statd: Monitoring protocol between NFS clients and servers
  • rpc.mountd: NFS mount daemon that implements, on the server side, mount requests from NFS v3 clients
  • rpc.idmapd: Maps NFSv4 names to local UIDs and GIDs
  • rpc.rquotad: Provides user quota information for remote users
  • rpcbind: Converts RPC program numbers to universal addresses
  • nfs-lock / rpc-statd : NFS file Lock

Key NFS configuration files

  • /etc/exports: The main configuration file; controls which file systems are exported to remote hosts and specifies options
  • /etc/fstab: Used to control which file systems, including NFS directories, are mounted when the system boots
  • /etc/sysconfig/nfs: Used to control the ports on which the required RPC services run
  • /etc/hosts.allow, /etc/host.deny: Used for TCP wrapper-based access control to the NFS server.

Comparing version 4 with earlier versions

The following is a brief summary of the differences between NFSv4 and NFS versions 2 and 3.

  • The NFS version 2 and 3 protocols are Stateless, whereas the NFSv4 protocol introduces state. Information about the use of objects by NFSv4 clients is maintained on the server. Operations through the NFSv4 protocol, such as open, lock, read, and write, carry state information that notifies the server of the client's intentions for an object. The server can then return to the client information related to other clients that intend to use the same object. Using persistent opens on the server through the NFSv4 protocol prevents some cases where a file becomes locked while an NFS version 2 or 3 client is writing to it.
  • The NFSv4 protocol includes support for byte-range locking and share modes as part of the base protocol. Locking in NFSv4 is lease-based, requiring the NFSv4 client to maintain its connection with the server to keep the open and lock state it owns.
  • The NFSv4 protocol introduces a compound request format. An NFSv4 client can combine several simple operations (for example, LOOKUP, OPEN, and READ) into a single request to the server. Through a single request, NFSv4 can perform complex operations in one network exchange.
  • The NFSv4 protocol provides enhanced security mechanisms that surpass the other mechanisms required by earlier protocol versions. IBM i provides support for Kerberos 5 authentication and data protection in addition to traditional AUTH_SYS security. The security API used by NFSv4 makes it easy to add new security mechanisms in the future.
  • The NFSv4 protocol standardizes the representation of string data. All string data used by the protocol is represented in UTF-8 format on the network. User and group information is passed between client and server in string form rather than as numeric values as in earlier versions.
  • The NFSv4 protocol combines the separate component protocols of earlier NFS versions into a single protocol specification. The single contact point of the NFSv4 protocol can improve compatibility with network firewalls.
  • NFS version 4 requires RPC support for a streaming network transport protocol such as TCP. The NFSv4 support provided by IBM i uses TCP exclusively.

For more information about the NFSv4 protocol, see RFC 3530 http://www.ietf.org/rfc/rfc3530.txt.

Security settings

  • List only the shared directories that are strictly necessary in the /etc/exports file.

Projects

erichough/nfs-server
A lightweight, robust, flexible, and containerized NFS server.
https://hub.docker.com/r/erichough/nfs-server/
https://github.com/ehough/docker-nfs-server

Network-attached storage (NAS)

See also

Favorite site

How to settings

author Zer0 sitemap