歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu 10.10 NFS配置

Ubuntu 10.10 NFS配置

日期:2017/2/28 16:27:02   编辑:Linux教程

系統平台:virtualbox3.2.10+Ubuntu 10.10

安裝nfs:

#sudo apt-get install nfs-kernel-server

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

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

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

注:nfs允許掛載的目錄及權限,在文件/etc/exports中進行定義, 【LINUX公社 www.LinuxIDC.com 】各字段含義如下:

/home/xgc:要共享的目錄

* :允許所有的網段訪問

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設定

命令執行情況如下:

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

Copyright © Linux教程網 All Rights Reserved