嵌入式Linux經常使用服務配置之nfs服務配置

安裝nfs:

#sudo apt-get install nfs-kernel-serverlinux

Ubuntu 10.10中的已是最新版本了,無需安裝this

打開/etc/exports文件,在末尾加入:rest

/home/xgc *(rw,sync,no_root_squash)server

注:nfs容許掛載的目錄及權限,在文件/etc/exports中進行定義, 各字段含義以下:ip

/home/xgc:要共享的目錄ci

* :容許全部的網段訪問get

rw :讀寫權限同步

sync:資料同步寫入內在和硬盤it

no_root_squash:nfs客戶端共享目錄使用者權限io

重啓服務:

#sudo /etc/init.d/portmap restart <---重啓portmap,很重要

#sudo /etc/init.d/nfs-kernel-server restart <---重啓nfs服務

#showmount -e <---顯示共享出的目錄

注:nfs是一個RPC程序,使用它前,須要映射好端口,經過portmap設定

命令執行狀況以下:

xgc@xgc-VirtualBox:~$ 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

xgc@xgc-VirtualBox:~$ 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 ]

xgc@xgc-VirtualBox:~$ showmount -e

Export list for xgc-VirtualBox:

/home/xgc *

如今能夠在本機上試一下:

#sudo mount -t nfs localhost:/home/xgc /mnt

注:localhost爲本機linux的IP地址

這樣就把共享目錄掛到了/mnt目錄,取消掛載用:

#sudo umount /mnt

若是用在嵌入式設備上掛載,要加上參數-o nolock

相關文章
相關標籤/搜索