Telantan

Zedboard: NFS服务配置

0
阅读(15108)

Zedboard: NFS服务配置

NFS(Network File System)网络文件系统是一种将远程主机上的分区(目录)经网络挂载到本地系统的一种机制,在嵌入式开发中应用非常广泛,下面简要介绍基于Zedboard的配置过程。

1. NFS服务配置

检查主机是否安装NFS包,没有则安装

clip_image002[4]

通过编辑/etc/exports文件,设置NFS目录文件访问权限

vi /etc/exports 

/home/telantan/nfs     192.168.1.* (rw,sync,no_root_squash)

说明:

a) /home/telantan/nfs:允许其它计算机访问的目录

b) 192.168.1.*:被允许访问该目录的客户端IP地址

c) rw:可读可写

d) no_root_squash:表示客户端root用户对该目录具备写权

调用exportfs 查看和导出/etc/exports中设置的共享目录

exportfs

clip_image003[4]

确认RHEL6.3宿主机的本地IP地址,这里为192.168.1.50,

ip addr

clip_image005[4]

启动rpcbind和nfs服务

/etc/init.d/rpcbind start
/etc/init.d/nfs restart

clip_image006[4]

clip_image007[4]

在REHL6.3本机mount一下试试,

mount –t nfs 192.168.1.50:/home/telantan/nfs tmp

clip_image009[4]

报了权限错错误,别急,查看home权限,Group/Others是不能访问的,

clip_image010[4]

更加权限

chmod 777 /home/telantan

clip_image011[4]

clip_image012[4]

重新mount,成功,同时在桌面上出现一个tmp的目标

clip_image014[4]

进入tmp中,新建一个文件,结果出现了只读错误,

cd tmp
touch hello.c

clip_image015[4]

查看/etc/exports文件,发现在IP地址与(之间多写了空格,删除,重新exportfs

clip_image016[4]

exportfs -rv

clip_image017[4]

再次测试,

showmount –e 127.0.0.1
mount –t nfs 192.168.1.50:/home/telantan/nfs tmp
cd tmp
touch hello.c
ll

clip_image018[4]

进入/home/telantan/nfs中查看,多出了hello.c文件,

clip_image019[4]

2. Zynq客户端测试

Zedboard板上默认使用的是Digilent提供的OOB代码,需要确认其编译的linux内核是否支持NFS文件系统,

cat /proc/filesystems

clip_image020[4]

从输出结果中可以看到,这个内核是不支持NFS文件系统的,所以需要自己定制一个新内核。

linux源码可以从XILINX GIT中下载,默认的配置是使能NFS的,

clip_image021[4]

编译出新的内核文件,拷到SD卡,上电启动,再次检查文件系统,发现已经支持NFS 了,

clip_image022[4]

在Zed本地客户端建立pub文件夹,直接mount,

mkdir pub
mount –t nfs 192.168.1.50:/home/telantan/nfs tmp

clip_image023[4]

如果出现了上面的错误,也不要紧张,由于这里的文件系统是基于busybox构成的,所以需要使用下面的命令,

mount -o port=2049,nolock,proto=tcp 192.168.1.50:/home/telantan/nfs pub

clip_image024[4]

在Zed端编辑hello.c

clip_image025[4]

在RHEL6.3宿主机端发现hello.c的内容已经更新了,

vi hello.c

clip_image026[4]

clip_image027[4]

在宿主机端编译hello.c,

xgcc hello.c
ls

clip_image028[4]

然后在Zed客户端运行,

ls
chmod +x a.out
./a.out

clip_image029[4]