Debian 10 搭建 nfs 服务器
安装 nfs 服务器
bash
1 | [root@debian /root]# apt-get install nfs-kernel-server |
修改服务端配置文件
如果只使用客户端功能,可忽略此步操作。
plaintext
1 | [root@debian /root]# nano /etc/exports |
/home/username/mynfs 是我主机上的文件夹,是 nfs 服务器的根目录;
192.168.8.8 是我客户端的 ip;
rw,读写权限,sync,数据同步写入内存和硬盘,no_root_squash,NFS 服务器共享目录用户的属性,如果用户是 root,那么对于这个共享目录来说就具有 root 的权限。
检查配置是否有错
bash
1 | [root@debian /root]# source /etc/exports |
无错误提示,配置文件正确。
启动服务
plaintext
1 | [root@debian /root]# /etc/init.d/nfs-kernel-server restart |
客户端挂载
plaintext
1 | [root@debian /root]# mount -n -o nolock 192.168.8.8:/home/username/mynfs /home/username/nfs/ |
将
192.168.8.8:/home/username/mynfs
挂载到/home/username/nfs/
。
检查是否挂载上了
plaintext
1 | [root@debian /root]# df -h |
测试是否可以共享文件
客户端写:
plaintext
1 | [root@debian /home/username/nfs]# touch testfile |
服务器端查看:
plaintext
1 | [root@debian /home/username/nfs]# ls |
服务器端写:
plaintext
1 | [root@debian /home/username/nfs]# touch debian |
客户端查看:
plaintext
1 | [root@debian /home/username/nfs]# ls |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 AiKIKI!