sudo apt install nfs-kernel-server nfs-common -y
sudo systemctl status nfs-kernel-server
1、新建目录,如
sudo mkdir -p /home/nfs/rw
sudo mkdir -p /home/nfs/ro
2、编辑/etc/exports,将新增的目录添加进去
/home/nfs/rw *(rw,sync,no_subtree_check,no_root_squash)
/home/nfs/ro *(ro,sync,no_subtree_check,no_root_squash)
3、重启/etc/exports配置
sudo exportfs -f
4、重启nfs服务
sudo systemctl restart nfs-kernel-server
以MacOS挂载Linux文件共享文件为例:
创建挂载目录
mkdir -p ~/nfs/rw
mkdir -p ~/nfs/ro
挂载
sudo mount -o rw,nfsvers=4 10.211.55.5:/home/nfs/rw ~/nfs/rw
sudo mount -o rw,nfsvers=4 10.211.55.5:/home/nfs/ro ~/nfs/ro
若报下面的错误
mount_nfs: can't mount /home/nfs/rw from 10.211.55.5 onto /Users/kuxue/nfs/rw: Operation not permitted
mount: /Users/kuxue/nfs/rw failed with 1
编辑/etc/nfs.conf,添加 nfs.client.mount.options = resvport 设置NFS客户端使用保留端口进行挂载,再进行重新挂载