#apt-get install portmap <-------------客戶端和服務器的安裝
#apt-get install nfs-kernel-server <-------------或者#apt-get install nfs-user-server
#apt-get install nfs-common
#mkdir -p /home/cody/arm210/roofs_qtopia_qt4 <-------------建立共享目錄
#vi /etc/export <-------------配置文件
add
/home/cody/arm210/roofs_qtopia_qt4 *(rw,sync,no_root_squas) <-------------nfs共享目錄,它可以作爲開發板的根文件系統通過nfs掛載。
下面是一些NFS共享的常用參數:
ro 只讀訪問
rw 讀寫訪問
sync 所有數據在請求時寫入共享
async NFS在寫入數據前可以相應請求
secure NFS通過1024以下的安全TCP/IP端口發送
insecure NFS通過1024以上的端口發送
wdelay 如果多個用戶要寫入NFS目錄,則歸組寫入(默認)
no_wdelay 如果多個用戶要寫入NFS目錄,則立即寫入,當使用async時,無需此設置。
hide 在NFS共享目錄中不共享其子目錄
no_hide 共享NFS目錄的子目錄
subtree_check 如果共享/usr/bin之類的子目錄時,強制NFS檢查父目錄的權限(默認)
no_subtree_check 和上面相對,不檢查父目錄權限
all_squash 共享文件的UID和GID映射匿名用戶anonymous,適合公用目錄。
no_all_squash 保留共享文件的UID和GID(默認)
root_squash root用戶的所有請求映射成如anonymous用戶一樣的權限(默認)
no_root_squas root用戶具有根目錄的完全管理訪問權限
anonuid=xxx 指定NFS服務器/etc/passwd文件中匿名用戶的UID
anongid=xxx 指定NFS服務器/etc/passwd文件中匿名用戶的GID
#dpkg-reconfigure portmap <-------------對Should portmap be bound to the loopback address? 選N
#chmod 777 -R /home/cody/arm210/roofs_qtopia_qt4
#/etc/init.d/portmap restart
#/etc/init.d/nfs-kernel-server restart <-------------重啓服務
192.168.1.6 是nfs服務器的ip
測試:
cody@debian:/mnt$ sudo mount 192.168.1.6:/home/cody/arm210/rootfs_qtopia_qt4 /mnt/nfs
如果需要刪除掛載,使用umount /mnt/nfs
cody@debian:/mnt$ ls /mnt/nfs
bin dev home linuxrc opt root sys usr www
data etc lib mnt proc sbin tmp var
在開發板上使用NFS的時候,按照開發板手冊的步驟配置,到最後出現
nfs:server 192.168.1.6 is not responding,still trying
的錯誤,後來發現Linux命令行寫錯了網關,跟PC上配置的網關不一樣,不能寫192.168.1.1,而應該是寫NFS server的IP
原來的命令行:
Linux-CommandLine = console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.6://home/cody/arm210/rootfs_qtopia_qt4 ip=192.168.1.10:192.168.1.6:192.168.1.1:255.255.255.0:cody.hm:eth0:off
修改後:
Linux-CommandLine = console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.6://home/cody/arm210/rootfs_qtopia_qt4 ip=192.168.1.10:192.168.1.6:192.168.1.6:255.255.255.0:cody.hm:eth0:off