安裝環境: ubuntu 10.04 LTS
一、安裝步驟:
gxkj@ubuntu:~/Arm$ sudo apt-get install nfs-kernel-server
設置nfs服務的目標目錄
這裏假設是 /mnt/nfs(如果沒有的話建立一個,並用chmod 766 /mnt/nfs設置權限)
設置配置文件
gxkj@ubuntu:~/Arm$ sudo vi /etc/exports //在文件的最後追加如下一行
/mnt/nfs 192.168.*.*(rw,sync,no_root_squash)
注:各字段含義
/mnt/nfs:要共享的目錄
192.168.*.*:允許C段所有的網段訪問
rw :讀寫權限
sync:資料同步寫入內在和硬盤
no_root_squash:nfs客戶端共享目錄使用者權限查看nfs服務是否啓動
ps -e|grep nfs
出現如下:
637 ? 00:00:00 nfsiod
1400 ? 00:00:00 nfsd4
1401 ? 00:00:00 nfsd
1402 ? 00:00:00 nfsd
1403 ? 00:00:00 nfsd
1404 ? 00:00:00 nfsd
1405 ? 00:00:00 nfsd
1406 ? 00:00:00 nfsd
1407 ? 00:00:00 nfsd
1408 ? 00:00:00 nfsd表示啓動了
#sudo /etc/init.d/portmap start --啓動portmap
#sudo /etc/init.d/nfs-kernel-server start --啓動nfs服務#sudo /etc/init.d/portmap restart --重啓portmap
#sudo /etc/init.d/nfs-kernel-server restart --重啓nfs服務#sudo /etc/init.d/portmap stop --停止portmap
#sudo /etc/init.d/nfs-kernel-server stop --停止nfs服務
------------- 經過上面的折騰,NFS服務可以使用 -------------------
二、掛載
現在可以在本機上試一下:
#sudo mount -t nfs localhost:/mnt/nfs /mnt
注:localhost爲本機linux的IP地址嵌入式設備上掛載,要加上參數-o nolock
在開發板上使用的掛載命令:
mount -t nfs -o nolock 192.168.1.100:/mnt/nfs /mnt
三、取消掛載
umount /mnt
---------------------------------------------------------
掛載不上的可能問題
如果服務器端的防火牆有開着的話,會出現如下錯誤。
錯誤提示:mount: RPC: Unable to receive; errno = No route to host
mount: nfsmount failed: Bad file descriptor
mount: Mounting 192.168.0.100:/ on /mnt failed: Invalid argument
解決方法:掛掉防火牆