標籤:ubuntu nfs server kernel 嵌入式
安裝nfs:
#sudo apt-get install nfs-kernel-server
(1)設定共用目錄
運行命令
#gedit /etc/exports
編輯 nfs 服務的設定檔(注意:第一次開啟時該檔案是空的),添加以下內容:
/opt/FriendlyARM/mini2440/rootfs_qtopia_qt4 *(rw,sync,no_root_squash)
其中:
/opt/FriendlyARM/mini2440/rootfs_qtopia_qt4 表示 nfs 共用目錄,
它可以作為開發板
的根檔案系統通過 nfs 掛接;
* 表示所有的客戶機都可以掛接此目錄
rw 表示掛接此目錄的客戶機對該目錄有讀寫的權力
no_root_squash 表示允許掛接此目錄的客戶機享有該主機的 root 身份
(2)重啟服務:
#sudo /etc/init.d/portmap restart 重啟portmap,
#sudo /etc/init.d/nfs-kernel-server restart 重啟nfs服務
#showmount -e 顯示共用出的目錄
註:nfs是一個RPC程式,使用它前,需要映射好連接埠,通過portmap設定
命令執行情況如下:
[email protected]:~$sudo /etc/init.d/portmap 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 474
[email protected]:~$sudo /etc/init.d/nfs-kernel-server restart
* Stopping NFS kernel daemon [ OK ]
* Unexporting directories for NFS kernel daemon... [ OK ]
* Exporting directories for NFS kernel daemon...
exportfs: /etc/exports [1]: Neither ‘subtree_check‘ or ‘no_subtree_check‘ specified for export "*:/home/xgc".
Assuming default behaviour (‘no_subtree_check‘).
NOTE: this default has changed since nfs-utils version 1.0.x
[ OK ]
* Starting NFS kernel daemon [ OK ]
[email protected]:~$showmount -e
Export list for xgc-VirtualBox:
/home/kevin *
現在可以在本機上試一下:
#sudo mount -t nfs localhost:/opt/FriendlyARM/mini2440/rootfs_qtopia_qt4/mnt/
註:localhost為本機linux的IP地址
這樣就把共用目錄掛到了/mnt目錄,取消掛載用:
#sudo umount /mnt
如果用在嵌入式裝置上掛載,要加上參數-o nolock
我在開發板上使用的掛載命令:
mount -t nfs -o nolock 192.168.1.102:/opt/FriendlyARM/mini2440/rootfs_qtopia_qt4/mnt/
ubuntu驅動開發環境搭建之nfs