#sudo apt-get install nfs-kernel-server
配置:
#sudo vim /etc/exports
/home/akaedu *(rw,sync,no_root_squash)
注:nfs允许挂载的目录及权限,在文件/etc/exports中进行定义, 各字段含义如下:
/home/akaedu:要共享的目录
* :允许所有的网段访问
rw :读写权限
sync:资料同步写入内在和硬盘
no_root_squash:nfs客户端共享目录使用者权限
使用:
#sudo /etc/init.d/portmap restart #sudo /etc/init.d/nfs-kernel-server restart #showmount -e
注:nfs是一个RPC程序,使用它前,需要映射好端口,通过portmap设定
命令执行情况如下:
$ sudo /etc/init.d/portmap restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service portmap restart
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the restart(8) utility, e.g. restart portmap
portmap start/running, process 474
$ sudo /etc/init.d/nfs-kernel-server restart
* Stopping NFS kernel daemon [ OK ]
* Unexporting directories for NFS kernel daemon... [ OK ]
* Exporting directories for NFS kernel daemon...
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/home/akaedu".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x [ OK ]
* Starting NFS kernel daemon [ OK ]
挂载:
#sudo mount -t nfs ipaddr:/home/akaedu /mnt
注:ipaddr为本机linux的IP地址
卸载:
#sudo umount /mnt
如果用在嵌入式设备上挂载,要加上参数-o nolock