Ubuntu 默認是沒有nfs服務的,因此須要本身安裝node
一、安裝nfs服務版
apt-get install nfs-kernel-server
二、修改nsf配置文件
vi /etc/exports
在文件中添加nfs的目錄格式以下
/armnfs *(sync,rw)
存盤退出
三、在根目錄下創建nsf的目錄
mkdir /armnfs
修改該目錄的權限
chmod 777 -R /armnfs
四、重新啓動nfs
/etc/init.d/nfs-kernel-server restartlinux
五、測試nsfwindows
mount 192.168.1.99:/armnfs/ abc服務器
嵌入式要mount 的時候 使用網絡
mount -o nolock 192.168.1.99:/armnfs/new8120 /mnt/netless
注:在內核的配置裏面的ide
Networking options --->選項中oop
啓用 TCP/IP networking測試
啓用IP: kernel level autoconfigurationthis
General setup ---> 選項中 ,
Default kernel command string: (默認的內核命令行)
加入綠色字中的字符
root=/dev/nfs rw nfsroot=192.168.1.99:/armnfs/ ip=192.168.1.201 init=/linuxrc console=ttyS0
File system ---> Network File System --->選項
啓用 NFS file system support
啓用 Provide NFSv3 client support
啓用 Root file system on NFS
nfs配置:
less /etc/exports
/home/xx/ 192.168.0.*(rw,sync)
$ sudo /etc/init.d/portmap start
* Starting portmap daemon...
* Already running. [ OK ]
$sudo /etc/init.d/nfs-common start
* Starting NFS common utilities [ OK ]
$ sudo /etc/init.d/nfs-kernel-server start
* Exporting directories for NFS kernel daemon...
exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.0.*:/home/xx/".
Assuming default behaviour ('subtree_check').
NOTE: this default will change with nfs-utils version 1.1.0
[ OK ]
* Starting NFS kernel daemon [ OK ]
$ showmount -e
Export list for Qunhome:
/home/xx 192.168.0.*
彷佛都好了,但是 :
sudo mount 192.168.0.100:/home/xx /mnt
mount: 192.168.0.100:/home/xx failed, reason given by server: Permission denied
我裝的是7.04,和你出現了一樣的問題,之前我用6.06的時候是沒有問題的
不知道是否是7.04的bug阿,
配置portmap的時候,在etc目錄下就沒有找到host.allow和hosts.deny這倆個文件,我是本身新建的這倆個文件,之前我記得在etc目錄下是有的。
在/etc/exports下寫入你的IP地址,不要有*號。例如:(/home/zwg IP(rw,sync,no_root_squash))
緣由多是etc目錄下沒有hosts.allow和hosts.deny這倆個文件。
我裝的是7.04,和你出現了一樣的問題,之前我用6.06的時候是沒有問題的
不知道是否是7.04的bug阿,
配置portmap的時候,在etc目錄下就沒有找到host.allow和hosts.deny這倆個文件,我是本身新建的這倆個文件,之前我記得在etc目錄下是有的。
很是感謝!
我刪除了安裝文件和全部相關配置文件
而後一步步從新來,最後成功了
作的改動爲:
在/etc/hosts中用IP lists 代替 *
還有一種方法:安裝配置的沒有大問題。不妨在括號里加上no_subtree_check選項,這是減小文件共享訪問檢查的,若是你的共享目錄在本地沒有不少讀寫請求的話(man exports)。
On the master node, edit your /etc/hosts.allow file to allow connections from slave nodes. If your cluster LAN is on 192.168.1.0/24, your hosts.allow will look like:
Code Listing 2.10: hosts.allow
portmap:192.168.1.0/255.255.255.0
Edit the /etc/exports file of the master node to export a work directory structure (/home is good for this).
Code Listing 2.11: /etc/exports
/home/ *(rw)
把hosts.deny刪除。子網用掩碼的方法表示。
NFS(Network File System, 網絡文件系統)能夠經過網絡將分享不一樣主機(不一樣的OS)的目錄——能夠經過NFS掛載遠程主機的目錄, 訪問該目錄就像訪問本地目錄同樣!
通常而言, 使用nfs可以方便地使各unix-like系統之間實現共享. 但若是須要在unix-like和windows系統之間共享, 就得使用samba了!
NFS運行在SUN的RPC(Remote Procedure Call, 遠程過程調用)基礎上, RPC定義了一種與系統無關的方法來實現進程間通訊. 由此, NFS server也能夠看做是RPC server.
正由於NFS是一個RPC服務程序, 因此在使用它以前, 先要映射好端口——經過portmap設定. 好比: 某個NFS client發起NFS服務請求時, 它須要先獲得一個端口(port). 因此它先經過portmap獲得port number. (不只NFS, 全部的RPC服務程序啓動以前, 都須要設定好portmap)
與NFS相關的幾個文件, 命令
1, /etc/exports
對NFS卷的訪問是由exports來批准, 它枚舉了若干有權訪問NFS服務器上文件系統的主機名.
2, /sbin/exportfs
維護NFS的資源共享. 能夠經過它從新設定 /etc/exports 的共享目錄, 卸載NFS Server共享的目錄或者從新共享等.
3, /usr/sbin/showmount
用在 NFS Server 端,而 showmount 則主要用在 Client 端. showmount 能夠用來查看 NFS 共享的目錄資源.
4, /var/lib/nfs/xtab
NFS的記錄文檔: 經過它能夠查看有哪些Client 鏈接到NFS主機的記錄.
下面這幾個並不直接負責NFS, 實際上它們負責全部的RPC
5, /etc/default/portmap
實際上, portmap負責映射全部的RPC服務端口, 它的內容很是很是之簡單(後面詳述)
6, /etc/hosts.deny
設定拒絕portmap服務的主機
7, /etc/hosts.allow
設定容許portmap服務的主機
安裝NFS
Debian/Ubuntu上默認是沒有安裝NFS服務器的,首先要安裝NFS服務程序:
$ sudo apt-get install nfs-kernel-server
(安裝nfs-kernel-server時,apt會自動安裝nfs-common和portmap)
這樣,宿主機就至關於NFS Server。
一樣地,目標系統做爲NFS的客戶端,須要安裝NFS客戶端程序。若是是Debian/Ubuntu系統,則須要安裝nfs-common。
$ sudo apt-get install nfs-commmon
nfs-common和nfs-kernel-server都依賴於portmap!
配置NFS
配置portmap
方法1: 編輯/etc/default/portmap, 將 -i 127.0.0.1 去掉.
方法2: $ sudo dpkg-reconfigure portmap , 對Should portmap be bound to the loopback address? 選N.
配置/etc/hosts.deny
(禁止任何host(主機)能和你的NFS服務器進行NFS鏈接),加入:
### NFS DAEMONS
portmap:ALL
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL
配 置/etc/hosts.allow
容許那些你想要的主機和你的NFS服務器創建鏈接。下列步驟將容許任何IP地址以192.168.2開頭的主機(連 接到NFS服務器上),也能夠指定特定的IP地址。參看man頁 hosts_access(5), hosts_options(5)。加入:
### NFS DAEMONS
portmap: 192.168.2.
lockd: 192.168.2.
rquotad: 192.168.2.
mountd: 192.168.2.
statd: 192.168.2.
/etc/hosts.deny 和 /etc/hosts.allow 設置對portmap的訪問. 採用這兩個配置文件有點相似"mask"的意思. 如今/etc/hosts.deny中禁止全部用戶對portmap的訪問. 再在/etc/hosts.allow 中容許某些用戶對portmap的訪問.
運行 $ sudo /etc/init.d/portmap restart 重啓portmap daemon.
配置/etc/exports
NFS掛載目錄及權限由/etc/exports文件定義
好比我要將將個人home目錄中的/home/zp/share目錄讓192.168.2.*的IP共享, 則在該文件末尾添加下列語句:
/home/zp/share 192.168.2.*(rw,sync,no_root_squash)
或者:/home/zp/share 192.168.2.0/24(rw,sync,no_root_squash)
192.168.2.* 網段內的NFS客戶端可以共享NFS服務器/home/zp/share目錄內容.且有讀,寫權限, 而且該用戶進入/home/zp/share目錄後的身份爲root
最好加上sync, 不然 $ sudo exportfs -r 時會給出警告, sync是NFS的默認選項.
(運行 $ showmount -e 查看NFS server的export list.
若更改了/etc/exports, 運行 $ sudo exportfs -r 更新
運行 $ sudo /etc/init.d/nfs-kernel-server restart 重啓nfs服務)
/etc/exports實際上就是nfs服務器的核心配置文件了. 鳥哥的Linux私房菜列舉了一些exports文件的寫法.
測試NFS
能夠嘗試一下掛載本地磁盤(假設本地主機IP地址爲:192.128.2.1,將/home/zp/share掛載到/mnt)
$ sudo mount 192.168.2.1:/home/zp/share /mnt
運行 $ df 看看結果
$ sudo umount /mnt 注意被拷貝文件的讀/寫權限! 另外, 可使用必定的參數: 使用加參數的辦法:mount -o nolock,rsize=1024,wsize=1024,timeo=15 192.168.2.130:/tmp/ /tmp/