linux的NFS详细配置方法

ubuntu12.04的NFS配置

(2012-09-19 17:39:33)
转载
标签:

杂谈

分类:linux基础
ubuntu12.04的NFS配置

安装nfs:

#sudo apt-getinstall nfs-kernel-server

ubuntu12.04中的已经是最新版本了,无需安装

打开/etc/exports文件,在末尾加入:

/home/kevin*(rw,sync,no_root_squash)

注:nfs允许挂载的目录及权限,在文件/etc/exports中进行定义,各字段含义如下:

/home/kevin:要共享的目录

*:允许所有的网段访问

rw:读写权限

sync:资料同步写入内在和硬盘

no_root_squash:nfs客户端共享目录使用者权限

重启服务:
#sudo /etc/init.d/portmaprestart <---重启portmap,
#sudo/etc/init.d/nfs-kernel-server restart <---重启nfs服务
#showmount -e <---显示共享出的目录

注:nfs是一个RPC程序,使用它前,需要映射好端口,通过portmap设定

命令执行情况如下:

kevin@ubuntu:~$sudo/etc/init.d/portmap restart
Rather than invoking initscripts through /etc/init.d, use the service(8)
utility, e.g. service portmap restart

Since the script you areattempting to invoke has been converted to an
Upstart job, you may also use the restart(8) utility, e.g. restartportmap
portmap start/running, process 474


kevin@ubuntu:~$sudo/etc/init.d/nfs-kernel-server restart
* Stopping NFSkernel 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/xgc".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x
[ OK ]
* Starting NFS kernel daemon [ OK ]

kevin@ubuntu:~$showmount-e
Export list for xgc-VirtualBox:
/home/kevin *

现在可以在本机上试一下:
#sudo mount -t nfslocalhost:/home/kevin /mnt

注:localhost为本机linux的IP地址

这样就把共享目录挂到了/mnt目录,取消挂载用:
#sudo umount /mnt

如果用在嵌入式设备上挂载,要加上参数-onolock

我在开发板上使用的挂载命令:

mount -t nfs -onolock 192.168.1.8:/home/kevin /mnt

你可能感兴趣的:(linux的NFS详细配置方法)