如何配置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