如何配置nfs及下载文件至开发板


(本文是我以前所写,放在此处,以备今后学习查看)

经过几个小时的探索,终于把nfs配置成功,并成功的将文件下载到开发板上,将参考来的资料和自己的心得总结在这里。

首先安装NFS,好多网页都是先默认你安装好的,这个还找了一会。。。

$ sudo apt-get install nfs-kernel-server
$ sudo apt-get install nfs-common
下一步,修改/etc/hosts.allow和/etc/hosts.deny,这个我其实不知道需不需要改不改,不过我是改了,而且后面出现的问题还和这个有关系。

更改 /etc/hosts.deny,在最后加入:

### NFS DAEMONS
  portmap: ALL
  lockd:      ALL
  mountd:  ALL
  rquotad:  ALL
  statd:      ALL
更改 /etc/hosts.allow,在最后加入:

### NFS DAEMONS
  portmap: 192.168.1.
  lockd:      192.168.1.
  rquotad:  192.168.1.
  mountd:   192.168.1.
  statd:       192.168.1.

这里要改为你的主机和开发板同一个网段。

#sudo /etc/rc.d/init.d/portmap start(如果说找不到,就执行 #sudo /etc/init.d/portmap start),启动端口映射。

配置/etc/exports
输入:/home/work 192.168.1.*(rw,sync,no_root_squash)

在这里/home/work就是你要共享的文件夹。

然后输入sudo  exportfs -r更新

#sudo /etc/rc.d/init.d/nfs start(找不到,执行 #sudo /etc/init.d/nfs start或#sudo /etc/init.d/nfs-kernel-server start)重启nfs服务。

现在可以先在自己的主机上挂载一下,输入mount -t nfs 192.168.1.110:/home/work /mnt,这时可能会出现
mount.nfs:access denied by server while mounting,这时候可以重新配置一下/etc/exports,将192.168.1.*替换为*,当然我替换后也没能好使,不过重启系统后好使了,大家都可以尝试一下。
挂载成功后,在/mnt下就会有/home/work下的文件了,如果要卸载,输入umount /mnt,这时可能会出现:device is busy ,这时候输入fuser -k /mnt,作用是杀死占用的进程,然后再输入umount /mnt就可以了。

打开开发板,输入mount -t nfs 192.168.1.110:/home/work /mnt,可能会输出:mount rpc unable to receive errno connection refused,这时更改/etc/hosts.allow设置使网段和开发板相同即可。如果出现:mount: can`t find/mnt in /etc/fstable or /etc/mtab,我是建立了一个新的目录,将/home/work挂载到这个新建的目录就可以了。

如果出现:rpcbind: server localhost not responding, timed out这样的超时情况,则需要在输入命令后加-o nolock,即为mount -t nfs 192.168.1.110:/home/work /mnt -o nolock。

解决这一系列的问题,就可以挂载成功了,这个时候你的目录下就会用/home/work中的内容了。

全文完。。。。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM