nfs-storage
它能做什么
这个工具可以帮你设置电脑之间通过网络共享文件。其中一台电脑作为存储文件的“服务器”,其他电脑(“客户端”)可以像访问自己的磁盘一样访问这些文件。
适用场景
- ✓需要多台 Linux 电脑访问同一批文件时。
- ✓想为应用数据或用户主目录搭建一个集中存储空间时。
- ✓在使用 Kubernetes 等容器系统、需要共享存储时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/nfs-storage/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“设置一个 NFS 服务器,以读写权限共享 /data 文件夹给 192.168.1.0/24 网段。”
每周 5 个新技能,1 分钟读完。
工作原理
你需要在服务器和客户端上安装 NFS 软件。然后配置服务器上哪些文件夹要共享,以及客户端如何访问它们,并设定权限。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
NFS Storage
Configure NFS servers and clients for network file sharing across Linux systems. Covers NFSv4 server setup, export options, client mounting, autofs for on-demand mounts, Kerberos security, performance tuning, and Kubernetes integration.
When to Use
- Sharing directories between multiple Linux servers (web farms, build clusters)
- Providing shared storage for containerized workloads (Kubernetes ReadWriteMany)
- Centralizing home directories or application data across a fleet
- Setting up a development environment with shared project files
- Migrating from local storage to network-attached storage
Prerequisites
- NFS server:
nfs-kernel-server(Debian/Ubuntu) ornfs-utils(RHEL/CentOS) - NFS client:
nfs-common(Debian/Ubuntu) ornfs-utils(RHEL/CentOS) - Network connectivity between server and clients (TCP/UDP 2049 for NFSv4)
- Firewall rules allowing NFS traffic
- For NFSv4 Kerberos:
krb5-userand a functioning KDC
NFS Server Setup
Installation
# Debian / Ubuntu
apt update && apt install -y nfs-kernel-server
# RHEL / CentOS
dnf install -y nfs-utils
# Enable and start the NFS server
systemctl enable --now nfs-server
# Verify NFS is running
systemctl status nfs-server
rpcinfo -p | grep nfs
Export Configuration (/etc/exports)
# /etc/exports
# Syntax: <directory> <client-spec>(options)
# Share /data to a specific subnet with read-write access
/data 10.0.0.0/24(rw,sync,no_subtree_check,no_root_squash)
# Share /shared read-only to everyone
/shared *(ro,sync,no_subtree_check)
# Share /home to specific hosts
/home server01.example.com(rw,sync,no_subtree_check)
/home server02.example.com(rw,sync,no_subtree_check)
# Share /var/nfs/projects with root squash (default, map root to nobody)
/var/nfs/projects 10.0.0.0/24(rw,sync,no_subtree_check,root_squash)
# NFSv4 pseudo-root export (recommended for NFSv4)
/srv/nfs 10.0.0.0/24(rw,sync,fsid=0,crossmnt,no_subtree_check)
/srv/nfs/data 10.0.0.0/24(rw,sync,no_subtree_check,no_root_squash)
/srv/nfs/shared 10.0.0.0/24(ro,sync,no_subtree_check)
Export Options Explained
| Option | Description |
|---|---|
rw |
Read-write access |
ro |
Read-only access |
sync |
Write data to disk before replying (safe, slower) |
async |
Reply before data is written to disk (fast, risk of corruption) |
no_subtree_check |
Disable subtree checking (improves reliability) |
root_squash |
Map remote root (UID 0) to nobody (default, more secure) |
no_root_squash |
Allow remote root to act as root on the server (use cautiously) |
all_squash |
Map all remote UIDs/GIDs to nobody |
anonuid=1000 |
Map anonymous users to a specific UID |
anongid=1000 |
Map anonymous groups to a specific GID |
crossmnt |
Allow clients to traverse into sub-mounts |
fsid=0 |
Mark as the NFSv4 pseudo-root |
Applying Export Changes
# Apply changes to exports (no server restart needed)
exportfs -ra
# Show current exports
exportfs -v
# Export a new directory on the fly (temporary, not persistent)
exportfs -o rw,sync,no_subtree_check 10.0.0.0/24:/tmp/share
# Unexport a directory
exportfs -u 10.0.0.0/24:/tmp/share
Server Firewall Configuration
# UFW (Ubuntu)
ufw allow from 10.0.0.0/24 to any port nfs
ufw allow from 10.0.0.0/24 to any port 111 # rpcbind (NFSv3)
# firewalld (RHEL/CentOS)
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload
# NFSv4 only needs TCP 2049 (no rpcbind or mountd)
firewall-cmd --permanent --add-port=2049/tcp
firewall-cmd --reload
NFS Client Configuration
Manual Mounting
# Install NFS client
apt install -y nfs-common # Debian/Ubuntu
dnf install -y nfs-utils # RHEL/CentOS
# Discover exports from the server
showmount -e nfs-server.example.com
# Mount an NFS share manually
mkdir -p /mnt/data
mount -t nfs nfs-server.example.com:/data /mnt/data
# Mount with specific NFS version and options
mount -t nfs -o vers=4.2,tcp,hard,intr nfs-server.example.com:/data /mnt/data
# Verify the mount
mount | grep nfs
df -hT /mnt/data
# Unmount
umount /mnt/data
Persistent Mounts via /etc/fstab
# /etc/fstab entries for NFS
# Basic NFSv4 mount
nfs-server.example.com:/data /mnt/data nfs4 defaults,_netdev 0 0
# Mount with performance and reliability options
…
常见问题
什么是 NFS?
NFS 全称 Network File System(网络文件系统),是一种协议,允许一台电脑通过网络访问另一台电脑上的文件,就像访问本地文件一样。
NFS 服务器和客户端有什么区别?
服务器是存储并共享文件的电脑,客户端是访问服务器所共享文件的电脑。
我可以把文件夹设置为只读共享吗?
可以。你可以把文件夹配置为只允许读取,确保客户端无法修改文件。
详情
作者的原始描述
Configure NFS servers and clients. Implement network file sharing for Linux systems. Use when setting up shared storage.
热度
- GitHub 星标
- 48k
- 排名
- #5304
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。