ubuntu NFS环境的搭建

来源:互联网 发布:黑客帝国动画版矩阵化 编辑:程序博客网 时间:2024/05/19 12:23

目的:在开发板的linux系统访问宿主系统(PC机)的文件,这样方便将宿主系统的文件传到开发板中。PS:也可以通过tfp传。

宿主系统:x86PC机, unbuntu9.04   (作为NFS服务器)

开发板:OMAP4,ubuntu12.04(为NFS客户端)

条件: 宿住系统和开发板在同一个局域网内或者宿主机有公网IP。


1. 在PC机端安装NFS服务器,同时安装客启端方便测试

sudo apt-get install nfs-kernel-server  nfs-common  portmap

2、配置挂载目录和权限
vim /etc/exports
配置如下:
# /etc/exports: the access control list for filesystems which may be exported
 to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync) hostname2(ro,sync)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt)
# /srv/nfs4/homes  gss/krb5i(rw,sync)

/home/nfsroot   *(rw,sync)
解释如下:
/home/nfsboot是NFS的共享目录,*表示任何IP都可以共享这个目录,你可以改为受限的IP,rw表示的是权限,sync是默认的。
另外如果还有其它读写权限问题,那就:chmod 777 /home/nfsroot  
3、重启NFS服务
 sudo /etc/init.d/nfs-kernel-server restart 重启nfs服务
4.测试( 172.3.32.119为PC机的IP)
sudo mount 172.3.32.119:/home/nfsroot   /mnt/tmp
执行:df  -h 查看挂载情况
5.在开发板上安装NFS客启端
sudo apt-get install  nfs-common

6. 挂载(172.3.32.119为PC机即NFS服务端的IP

sudo mount 172.3.32.119:/home/nfsroot   /home/nfs

注意:如果挂载不成功,请先ping 172.3.32.119看开发板是否能通过网络连接上PC机,如果不行,那请先检测网络!!


参考:http://blog.163.com/lucien_cc/blog/static/130290562201022073634446/

http://linux.chinaunix.net/techdoc/system/2009/02/06/1060861.shtml