「LINUX-NFS」- 内核实现的 NFS 服务

认识

官网:https://linux-nfs.org/
文档:

组成

nfs-utils

Both client and server only require the installation of the nfs-utils package.

服务端配置 | 配置文件路径 | Server Configuration

不同 Linux 发行版组织 NFS 服务的方式并不相同,建议阅读发行版手册,以了解配置文件的详细路径。

for Ubuntu 20.04 | Ubuntu/Network File System (NFS)

/etc/default/nfs-common

/etc/default/nfs/kernel-server

在配置文件中,参数 NEED_* 控制某个服务是否被运行。但是,在基于 systemd 的安装中,该参数并不会生效。需要通过 systemctl 来直接管理服务。

for Ubuntu 22.04 | Ubuntu/Network File System (NFS)

/etc/nfs.conf:a INI-style config file, see the nfs.conf(5) manpage for details.

/etc/nfs.conf.d/:其中的 *.conf 文件将覆盖 nfs.conf 的配置;

命令 nfsconf(8) 能够用来查看(或配置)nfs.conf 文件

将 Ubuntu 20.04 升级到 Ubuntu 22.04 时,脚本将进行配置转换,以生成 nfs.conf 文件。参考
Ubuntu/Network File System (NFS) 文档,以获取更多细节信息。

构建

https://nfs.sourceforge.net/nfs-howto/

on Ubuntu 25.04

现在 NFS 实现及工具很多,我们感到困惑,所以我们尝试弄清楚部署的到底是哪个版本。

libnfsidmap1 https://linux-nfs.org/
libnfsidmap-dev https://linux-nfs.org/
libnfsidmap-regex https://linux-nfs.org/

nfs4-acl-tools http://linux-nfs.org/

nfs-common https://linux-nfs.org/
nfs-kernel-server https://linux-nfs.org/

nfsometer https://wiki.linux-nfs.org/wiki/index.php/NFSometer
nfstest https://wiki.linux-nfs.org/wiki/index.php/NFStest

应用

查看所有已连接客户端 Finding NFS Clients

How to get the list of clients connected to an NFS server within a local network?
man 8 showmount

为了进行某些变更操作,我们需要查看所有挂载 NFS 服务的客户端。

官网手册并不建议使用 showmount -a 命令,因为结果并不可靠。Note, however, that there is little to guarantee that the contents of /var/lib/nfs/rmtab are accurate. A client may continue accessing an export even after invoking UMNT. If the client reboots without sending a UMNT request, stale entries remain for that client in /var/lib/nfs/rmtab.

使用 netstat 命令,查看已建立的连接,能够得到准确结果:

netstat -an | grep 2049

参考

ArchWiki / NFS / https://wiki.archlinux.org/title/NFS

官方文档

linux-nfs.org / Main Page
https://linux-nfs.org/wiki/index.php/Main_Page

Linux NFS Overview, FAQ and HOWTO Documents
https://nfs.sourceforge.net/

Ubuntu / NFSv4Howto
https://help.ubuntu.com/community/NFSv4Howto?_ga=2.96445276.1120247715.1700808114-1443535799.1696832186

Ubuntu / SettingUpNFSHowTo
https://help.ubuntu.com/community/SettingUpNFSHowTo?_ga=2.96445276.1120247715.1700808114-1443535799.1696832186