1. 程式人生 > >Ubuntu14.04 nfs伺服器安裝配置

Ubuntu14.04 nfs伺服器安裝配置

1.安裝nfs伺服器


[email protected]:~$ dpkg -l |grep nfs    #檢視是否安裝有nfs
[email protected]:~$ sudo apt-get install nfs-kernel-server
[email protected]:~$ dpkg -l |grep nfs
ii  libnfsidmap2:amd64                                    0.25-5                                              amd64        NFS idmapping library
ii  nfs-common                                            1:1.2.8-6ubuntu1.2                                  amd64        NFS support files common to client and server
ii  nfs-kernel-server                                     1:1.2.8-6ubuntu1.2                                  amd64        support for NFS kernel server

2.建立nfs專用資料夾


[email protected]:~$ sudo mkdir -p /nfs/disk
#NFS共享目錄可以是主機的任何一個目錄,為了方便使用,最好將許可權設定為777

3.配置nfs


[email protected]:~$ sudo vim /etc/exports

#在最後一行加
/nfs/disk *(rw,sync,no_root_squash,no_subtree_check)

前面那個目錄是與nfs服務客戶端共享的目錄,*代表允許所有的網段訪問(也可以使用具體的IP)
rw:掛接此目錄的客戶端對該共享目錄具有讀寫許可權
sync:資料同步寫入記憶體和硬碟
no_root_squash:客戶機用root訪問該共享資料夾時,不對映root使用者。(root_squash:客戶機用root使用者訪問該共享資料夾時,將root使用者對映成匿名使用者)
no_subtree_check:不檢查父目錄的許可權。

4、重啟rpcbind 服務

nfs是一個RPC程式,使用它前,需要對映好埠,通過rpcbind 設定。
[email protected]:~$ sudo service rpcbind restart
rpcbind stop/waiting
rpcbind start/running, process 12320

5、重啟nfs服務
[email protected]:~$ sudo service nfs-kernel-server  restart
 * Stopping NFS kernel daemon
   ...done.
 * Unexporting directories for NFS kernel daemon...
   ...done.
 * Exporting directories for NFS kernel daemon...
   ...done.
 * Starting NFS kernel daemon
   ...done.

6.測試nfs伺服器

#先到nfs共享目錄建立檔案
[email protected]:~$ cd /nfs/disk/
[email protected]:/nfs/disk$ touch test

#本地驗證NFS伺服器。將NFS伺服器目錄掛載到本機另外一個目錄下,可以看到掛載點目錄下可以看到NFS伺服器目錄中的檔案。
[email protected]:/nfs/disk$ sudo mount -t nfs 192.168.158.129:/nfs/disk /mnt/

[email protected]:/nfs/disk$ ls /mnt/
test

 #掛載成功後,可以在開發板的/mnt目錄下看到NFS伺服器上的檔案。

[email protected]:/nfs/disk$ sudo umount /mnt
[email protected]:/nfs/disk$ ls /mnt/
hgfs

 

#使用開發板與虛擬機器安裝的客戶系統進行NFS掛載,需要將虛擬網絡卡設定為Bridged模式,並建議使用靜態IP地址。

 

參考部落格:https://blog.csdn.net/xuezhimeng2010/article/details/42610673

https://www.cnblogs.com/zhenyuyaodidiao/p/4823855.html