2010年4月15日 星期四

Configuration of NFS Server and Client

[NFS Server]

Server端的部分有幾種選擇:
  1. pure Linux server
  2. Windows host with Cygwin
  3. Windows host with FreeNFS

(1)
pure Linux Server的部分大家應該都很熟悉
如果有點忘了也可以參考這邊
另外就是,有時候Linux server是共用的,你不見得擁有root權限
所以提供其他選擇讓大家參考

(2)
Cygwin也是很多人使用的環境
要架設NFS server你需要額外的packages
  • Net :: nfs-server
  • Libs :: sunrpc
  • Admin :: cygrunsrv
install完成之後,執行/usr/bin/nfs-server-config
接下來都回答yes,並提供user/passwd供windows services使用
接著cygwin會自動幫你install mountd/nfsd/portmap

上述動作都跑完之後,接著就是去修改/etc/exports來決定你想分享的目錄和權限

再來就是mountd/nfsd/portmap的使用,有兩種方式:

1. 從Windows的控制台->系統管理工具->服務
找到這三個,然後決定自動/手動/停用等選項

2. 從cygwin裡頭去下 /bin/cygrunsrv --stop/start/remove ....

Stop the services:

 cygrunsrv --stop mountd
cygrunsrv --stop nfsd
cygrunsrv --stop portmap

Remove the services:

 cygrunsrv --remove mountd
cygrunsrv --remove nfsd
cygrunsrv --remove portmap
最後就是記得把Windows防火牆針對這些app ports打開

更多內容請參考: 文章一 文章二

(3)
最後來介紹最簡單的設定工具
直接下載sourceforge上的這個freenfs project來用
馬上執行馬上通,很適合不想被眾多設定搞得一頭霧水的朋友們使用

下載點: FreeNFS

=================================================
[NFS Client]

這邊client的部分主要針對embedded target board上的設定
主要要改的有三大部分:
  1. Kernel
  2. uClibc
  3. mount (or busybox)
(1)
首先,要使用NFS是需要kernel的幫忙的
所以在menuconfig中,先找到

(1.1)
Networking --->
Networking support
Networking options --->
TCP/IP networking
[*] IP: kernel level configuration (把底下DHCP和BOOTP都選起來,RARP選起來也safe)

(1.2)
File systems --->
Network File Systems --->
<*>NFS file system support
[*] Provide NFSv3 client support
然後底下
[*]Root file system on NFS (如果你要做的是nfsroot,這邊一定要記得選)

(1.3)
如果是uClinux,在General Setup --->
可以把Initramfs source file設成empfs

(2)
uClibc的部分要支援
Networking Support --->
[*] Remote Procedure Call(RPC) support
[*] Full RPC support

(3)
mount的部分要支援
[*]mount: support NFS mounts

-------------
mount NFS有兩種case
  • mount any directory exported from nfs server
  • mount nfsroot at kernel booting
第一種直接在target shell下
mount -t nfs -o nolock 192.168.1.1:/pub /mnt/nfs

第二種需要傳入一些參數給kernel
方法也有兩種:
  • 直接在kernel menuconfig去寫command string要為何
Kernel command line: root=/dev/nfs rw nfsroot=192.168.0.17:/rootfs,nfsvers=3 ip=192.168.0.15:192.168.0.17:192.168.0.1:255.255.255.0:1:eth0:off
  • 從u-boot下去設環境變數
+ uboot> setenv ipaddr 192.168.1.254
+ uboot> setenv serverip 192.168.1.1
+ uboot> setenv bootargs root=/dev/nfs nfsroot=/tftpboot/rootfs ip=192.168.1.254:192.168.1.1::::eth0:off

參考網址:
uclinux-dist:nfs
[Buildroot] [PATCH] docs/howto: add howto for nfsroot
SkyEye: BootfromNFS
root_file_system_structure

======================================
[Buildroot]
要支持NFS,除了busybox的mount命令要支持NFS外,buildroot需要添加如下设置:
Toolchain----->[*]Enable RPC
Package Selection----->Networking----->[*]portmap

http://buildroot.busybox.net/buildroot.html