Ubuntu NFS(网络文件系统)安装

  • 安装nfs
sudo apt install nfs-kernel-server nfs-common -y
  • 查看nfs服务状态
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客户端使用保留端口进行挂载,再进行重新挂载
posted @ 2023-12-14 09:10  酷学大叔  阅读(76)  评论(0编辑  收藏  举报