在ubuntu上配置NFS

在ubuntu上配置NFS
主机平台:Ubuntu 12.04

1.开始使用命令更新安装最新版本

#sudo apt-get install nfs-kernel-server

ubuntu12.04中的已经是最新版本了

2.配置共享目录的路径和访问权限

安装好nfs-common和portmap后还需配置共享目录的路径和访问权限,NFS的配置文件是/etc/exports。

配置的格式如下:

[共享路径][主机名或IP地址(参数,参数)]

举例:

/home/zhcx/nfs_root192.168.1.111(rw,sync,no_root_squash)

3.重启服务:

#sudo /etc/init.d/portmap restart

#sudo /etc/init.d/portmap stop             

#sudo /etc/init.d/nfs-kernel-server restart     
#showmount -e                                   

#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/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 ]

#showmount -e
Export list for xgc-VirtualBox:
/home/zhcx/nfs_root

4.挂载文件 

现在可以在本机上试一下:
#sudo mount -t nfs localhost:/home/zhcx/nfs_root /mnt

注:localhost为本机linux的IP地址

这样就把共享目录挂到了/mnt目录,在目录/mnt中可以看得到目录/home/zhcx/nfs_root中的文件。

取消挂载用:
#sudo umount /mnt

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

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

mount -t nfs -o nolock 192.168.1.8:/home/zhcx/nfs_root /mnt



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值