ubuntu驱动开发环境搭建之nfs

安装nfs:

#sudo apt-get install nfs-kernel-server

(1)设置共享目录
运行命令
#gedit /etc/exports
编辑 nfs 服务的配置文件(注意:第一次打开时该文件是空的),添加以下内容:
/opt/FriendlyARM/mini2440/rootfs_qtopia_qt4 *(rw,sync,no_root_squash)
其中:
/opt/FriendlyARM/mini2440/rootfs_qtopia_qt4 表示 nfs 共享目录,
它可以作为开发板
的根文件系统通过 nfs 挂接;
* 表示所有的客户机都可以挂接此目录
rw 表示挂接此目录的客户机对该目录有读写的权力
no_root_squash 表示允许挂接此目录的客户机享有该主机的 root 身份

(2)重启服务:
#sudo /etc/init.d/portmap restart                    重启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 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


kevin@ubuntu:~$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 ]

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

 

现在可以在本机上试一下:
#sudo mount -t nfs localhost:/opt/FriendlyARM/mini2440/rootfs_qtopia_qt4/mnt/

注:localhost为本机linux的IP地址

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

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

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

mount -t nfs -o nolock 192.168.1.102:/opt/FriendlyARM/mini2440/rootfs_qtopia_qt4/mnt/

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值