启动NFS服务端
sudo systemctl start nfs-server
编辑/etc/exports
可以新增共享目录,下面是例子
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/share *(rw,sync,sec=sys,insecure,no_subtree_check)
NFS客户端
挂载操作
sudo mount -t nfs 192.168.8.3:/share /mnt/share
查看可以挂载的目录
showmount -e 192.168.8.3
卸载
umount /mnt/share
需要注意的是是WSL2挂载操作需要加上额外的参数,这是他的BUG
sudo mount -t nfs -o noresvport 192.168.8.3:/share /mnt/share
我的WSL使用的网络模式是networkingMode=mirrored
,希望后续官方可以修复这个问题