差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

下次修改
前次修改
nfs [2017/01/04 00:57]
127.0.0.1 建立
nfs [2018/02/20 11:50] (目前版本)
jz
行 1: 行 1:
-====== NFS ======+======= NFS =======
  
-edit ''/​etc/​exports''​+====== Server ======
  
 +===== exports =====
 +
 +create folder for exporting
 <​code>​ <​code>​
-/usr/​home/​public ​140.116.82.0/24 140.116.245.0/24 140.116.246.0/​24 -maproot=root +mkdir -p /home/nfs/public /home/nfs/private
-/usr/home/​private ​-ro 140.116.82.0/​24 140.116.245.0/​24 140.116.246.0/​24 -maproot=root+
 </​code>​ </​code>​
 +
 +vi ''/​etc/​exports''​
 +<​code>​
 +/​home/​nfs/​public -maproot=root -network=140.116.245.193/​26
 +/​home/​nfs/​private -maproot=root -ro -network=140.116.245.193/​26
 +</​code>​
 +
 +everytime exports is edited, use ''​service mountd reload''​ to reload
 +
 +
 +if ufs is used, without adding new disk, bind folder to folder like so:
 +<​code>​
 +mkdir -p /​var/​nfs/​public
 +mkdir -p /​var/​nfs/​private
 +vi /etc/fstab
 +</​code>​
 +
 +add following content to fstab, and remount by doing ''​mount -a''​
 +<​code>​
 +/​var/​nfs/​public ​ /​usr/​home/​nfs/​public ​ nullfs rw 0 0
 +/​var/​nfs/​private /​usr/​home/​nfs/​private nullfs rw 0 0
 +</​code>​
 +
 +
 +
 +if zfs is used, edit exports at ''/​etc/​zfs/​exports'',​
 +the exported path needs to be zfs dataset.
 +<​code>​
 +zfs create zroot/​usr/​home/​nfs
 +zfs create zroot/​usr/​home/​nfs/​public
 +zfs create zroot/​usr/​home/​nfs/​private
 +</​code>​
 +
 +==== service config ====
  
 add following to rc.conf add following to rc.conf
行 12: 行 48:
 rpcbind_enable="​YES"​ rpcbind_enable="​YES"​
 nfs_server_enable="​YES"​ nfs_server_enable="​YES"​
 +mountd_enable="​YES"​
 mountd_flags="​-r"​ mountd_flags="​-r"​
 </​code>​ </​code>​
 +
 +==== start service ====
  
 start nfs server start nfs server
行 20: 行 59:
 </​code>​ </​code>​
  
-if exports is edited, use ''​service mountd reload''​ to reload+====== Client ====== 
 + 
 +===== Service config ===== 
 +<​code>​ 
 +sysrc nfs_client_enable="​YES"​ 
 +</​code>​ 
 + 
 +==== Start NFS client ==== 
 + 
 +<​code>​ 
 +service nfsclient start 
 +</​code>​ 
 + 
 +===== Mount on startup ===== 
 + 
 +add following content into ''​/etc/fstab''​ 
 +<​code>​ 
 +# nfs 
 +10.0.15.31:/​home/​nfs/​public ​ /​home/​nfs/​public nfs ​      ​ rw,​vers=3,​proto=tcp 0 0 
 +10.0.15.31:/​home/​nfs/​private /​home/​nfs/​private ​ nfs       ​ rw,​vers=3,​proto=tcp 0 0 
 +</​code>​ 
 + 
 +create directory ​to be mount 
 +<code bash> 
 +mkdir -p /​home/​nfs/​public /​home/​nfs/​private 
 +</​code>​ 
 + 
 + 
 +===== Showmount ===== 
 +<​code>​ 
 +showmount <​servername>​ -e 
 +</​code>​