嵌入式開發板
中nfs 出現問題permission denied的問題
解決方法:
去看下你的服務啟動了沒,客戶端需要portmap服務,服務器端需要portmap、nfs服務。具體做法:
客戶端:/etc/init.d/portmap start
服務器端:/etc/init.d/portmap start
/etc/init.d/nfs start
另外/etc/exports配置文件要正確,以下供你參考:
假設你的導出目錄是/share,配置文件可以寫成
/share *(rw,sync,no_root_squash)
一些關于掛載解決問題的方法分析
#sudo
apt-get install nfs-kernel-server
打開/etc/exports文件,
sudo vi
/etc/exports在末尾加入:
/work/nfs_root/file_sys_yl *(rw,sync,no_root_squash)
其中的file_sys_yl就是新添加的掛載目錄
注:nfs允許掛載的目錄及權限,在文件/etc/exports中進行定義,各字段含義如下:
/work/nfs_root/file_sys_yl:要共享的目錄
*
:允許所有的網段訪問
rw
:讀寫權限
sync:資料同步寫入內在和硬盤
no_root_squash:nfs客戶端共享目錄使用者權限
重啟服務:
sudo
/etc/init.d/portmap
restart <---重啟portmap,
sudo
/etc/init.d/nfs-kernel-server
restart <---重啟nfs服務
showmount
-e <---顯示共享出的目錄
注:nfs是一個RPC程序,使用它前,需要映射好端口,通過portmap設定
命令執行情況如下:
kevin@ubuntu:~$sudo
/etc/init.d/portmap restart
rtmap restart
Rather than invoking init scripts through /etc/init.d, use the
service(8)
utility, e.g. service portmap restart
Since the script you are attempting to invoke has been converted
to an
Upstart job, you may also use the restart(8) utility, e.g.
restart portmap
portmap start/running, process 742
kevin@ubuntu:~$sudo
/etc/init.d/nfs-kernel-server
restart
*
Stopping NFS kernel daemon
...done.
* Unexporting directories for NFS kernel
daemon...
...done.
* Exporting directories for NFS kernel
daemon...
exportfs: /etc/exports [1]: Neither 'subtree_check' or
'no_subtree_check' specified for export
"*:/work/nfs_root".
Assuming default behaviour
('no_subtree_check').
NOTE: this default has changed since
nfs-utils version 1.0.x
exportfs: /etc/exports [2]: Neither 'subtree_check' or
'no_subtree_check' specified for export
"*:/work/nfs_root/first_fs".
Assuming default behaviour
('no_subtree_check').
NOTE: this default has changed since
nfs-utils version 1.0.x
...done.
* Starting NFS kernel
daemon
...done.
kevin@ubuntu:~$showmount
-e
Export list for
book-desktop:
/work/nfs_root/first_fs
*
/work/nfs_root
*
現在可以在本機上試一下:
#sudo mount -t nfs
localhost:/home/kevin /mnt
注:localhost為本機linux的IP地址
這樣就把共享目錄掛到了/mnt目錄,取消掛載用:
#sudo umount
/mnt
如果用在嵌入式設備上掛載,要加上參數-o
nolock
我在開發板上使用的掛載命令:
mount -t nfs -o nolock
59.68.190.128:/work/nfs_root/first_fs /mnt
,這樣就能在開發板上面查看到自己虛擬機中的文件了,
有一個問題就是找了很長時間,其實是/work/nfs_root/first_fs這個文件夾寫錯了,悲劇的我為了這一個錯誤找了一上午