linux 使用nfs 服务实现远程共享

首先安装

apt install -y nfs-kernel-server nfs-common

编辑配置文件

vim /etc/exports

添加内容:

/root/test *(rw,sync,no_root_squash)

参数含义:

首先是目录,然后星号表示任何ip都能访问

rw:读写,如果想要只读,可设为"o"
sync:数据同步写入硬盘
no_root_squash:当远程访问使用root用户时,不映射成匿名用户,如果想用映射,可设为"root_squash"
no_subtree_check:这个表示不确认父目录的权限,上面没设置这个

启动服务

/etc/init.d/nfs-kernel-server start

每次修改过配置文件得重启下:

/etc/init.d/nfs-kernel-server restart

查看共享出去的目录

showmount --exports

远程访问挂载

先安装nfs客户端(看本文最上面),建立/nfs目录,然后执行:

mount -t nfs 10.22.35.1:/root/test /nfs/

Windows 安装NFS与挂载目录

控制面板 - 程序和功能 - 打开或关闭 Windows 功能 - NFS 服务 - NFS 客户端

在控制台输入以下命令挂载:

mount 10.22.35.1:/root/test n:


原文地址:https://www.cnblogs.com/dhName/p/11229906.html