A network file system developed by Sun Microsystem Since 1980, and is available almost for all kinds of UNIX systems now.
A distributed file system that provide transparent access to remote disks. User access remote disks as if they are local.
Allows centralized administration of disks usage.
Proveide File system consistency, because there is only one copy of each file on the network.
NFS for Linux Since kernel 1.0.
NFS是一個通用於各種UNIX平台間的檔案分享協定。
NFS Server & NFS Client
An NFS server is a host that owns one or more file systems and makes them available on the network for other machines.
A NFS client mount filesystems from one or more servers.
提供NFS服務的三個程式(On the server)
rpc.portmapper
Convert Remote Procedure Call (RPC) program numbers into Internet Protocol port numbers. Needed also in NIS (YP) service. The name of this daemon depends on the UNIX vender! On linux it's“portmap”.portmap本身並不提供NFS服務,他的工作是將其他電腦的呼叫正確的對應到NFS或NIS程式。
RPC Portmapper (portmap)是一個server程式,功能是將RPC program number轉換為TCP/IP Port Number。
確定系統中RPC portmapper是否啟動的方法: (1). nmc:~# ps aux|grep port bin 62 0.0 0.2 976 376 ? S 12:40 0:00 /usr/sbin/rpc.portmap root 3990 0.0 0.2 1052 368 p2 S 08:36 0:00 grep port (2). nmc:~# rpcinfo -p program vers proto port 100000 2 tcp 111 portmapper 100000 2 udp 111 portmapper 100005 1 udp 669 mountd 100005 2 udp 669 mountd 100005 1 tcp 672 mountd 100005 2 tcp 672 mountd 100003 2 udp 2049 nfs 100003 2 tcp 2049 nfs 100007 2 udp 721 ypbind 100007 2 tcp 723 ypbind
rpc.mountd Answer file system mount requests. Read the /etc/exports file to determine which file system are available to which machines and which users. The name of this daemon depends on the UNIX vender! On linux it's "rpc.mountd" rpc.mountd提供遠端電腦架設(mount)及卸載(umount)檔案系統的服務
rpc.nfsd Handle file requests from clients. How many nfsd to be started depends on the load expected on that server. To start n nfsds just enter"nfsd n". Duplicated nfsds can serve multiple files request concurrently ! The name of this daemon depends on the UNIX vender! On linux the name is "rpc.nfsd". rpc.nfsd會將對NFS的要求轉換成為本地檔案系統的實際要求。
啟動NFS Server
『/etc/rc.d/init.d/nfs start』or just type 『/usr/sbin/mountd; /usr/sbin/nfsd 8』
停止NFS Server
『/etc/rc.d/init.d/nfs stop』
Monitor NFS Server Status
『/etc/rc.d/init.d/nfs status』
NFS Server組態設定(/etc/exports)
/etc/exports define the access control list (ACL) for file systems which are exported to NFS clients
NFS檔案分享(export)最小單位為"directory"
Format of /etc/exports /directory/to/export host1(permission) host2(permission) ... hostx 的格式可以是:
* "*"代表所有主機皆可存取
主機名稱 主機名稱應定義在DNS、/etc/hosts或NIS中
IP Address[/netmask] 140.120.2.0/24 (相當於140.120.2.0/255.255.255.0) 140.120.2.0/16 (相當於140.120.2.0/255.255.0.0)
/etc/exports一經修改必須讓rpc.mountd及rpc.nfs重讀該檔案。方法有二:一為重新啟動NFS By : /etc/rc.d/init.d/nfs restart ,另一個則是By指令"exportfs -a"
Example /home nmc1(rw) nmc2(ro) nmc3(rw,no_root_squash)
mount NFS file system
指令格式: mount -o 參數 server_name:/exported/dir /local/dir/to_mount server_name NFS Server /exported/dir NFS Server /etc/exports中export的directory /local/dir/to_mount 這是local mount point,通常是一個已經存在的空目錄 參數
rw 讀寫
ro read only
bg background mount (mount process go to background in case of mount fail !)
soft soft mount(default NFS mount is "hard mount",hard mount will keep on trying till mount completed,soft mount will return error code after number of unsuccessful trying specified in "retrans"