NFS
NFS 即网络文件系统(Network File-System)
因文件夹需要在不同 Linux 设备上同步的原因,又想偷个懒。
安装
安装 NFS服务器端
| 1 | sudo apt-get install nfs-kernel-server | 
安装 NFS客户端
| 1 | sudo apt-get install nfs-common | 
配置
配置格式说明
DIR IP(读写权限,sync,no_root_squash)
DIR
共享目录
IP
所有 ping 通该主机的用户 : *
指定网段,在该网段中的用户可以挂载 : 192.168.1.*
指定IP用户能挂载 : 192.168.1.12
读写权限
ro : 只读
rw : 读写
sync
同步
no_root_squash
不降低root用户的权限
打开 NFS 配置文件
| 1 | sudo vim /etc/exports | 
| 1 | /opt/gitlab-runner/android-sdk 10.0.2.240(rw,sync,no_root_squash) | 
验证
| 1 | sudo mount -t nfs 10.0.0.239:/opt/gitlab-runner/android-sdk /mnt/android-sdk-remote-nfs -o nolock | 
连接到个人目录下
| 1 | ln -s /mnt/android-sdk-remote-nfs /home/ubuntu/Android/sdk-remote | 
手动挂载成功后,就可以配置为服务开机启动(systemd)
测试读写速度
在当前目录下,以 io-test.dbf 文件来测试读写性能
| 1 | time dd if=/dev/zero of=io-test.dbf bs=4k count=10000 | 
Windows 挂载
挂载块大小指定为 64KB
| 1 | mount \\192.168.55.88\mnt\ceph\data\Android -o rsize=64,wsize=64,iocharset=utf8,timeo=15 X:\ | 
卸载
| 1 | umount X: | 
NFS 默认 uid、gid 修改为 1055
NFS共享目录挂载时uid和gid均为-2,而NFS服务的默认 uid 和 gid 为 65534,因此此时仅有共享目录的读权限。
修改注册表 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default
添加DWORD值两项:AnonymousUid,AnonymousGid ,选择10进制,填入 1055
重启 NFS 服务
| 1 | sudo /etc/init.d/nfs-kernel-server restart |