寫個註解好了,以免之後又要重新google

 

實例:

在Apple上新增NFS分享的路徑(/Volumes/Raid1/L15_1),並mount到自己的機器上 (/NFS)

 

============================================================================

Apple NFS Server

Apple上的/etc/exports是開機時才透過 '/System/Library/StartupItems/NFS/NFS' 此指令檔寫入設定

原始/etc/exports內容:

 

# GENERATED FILE - DO NOT EDIT!
# Make changes under /exports in NetInfo Manager
/Volumes/Raid2/L19_2    -network 192.168.205.0 -mask 255.255.255.0
/Volumes/Raid1/L19_1    -network 192.168.205.0 -mask 255.255.255.0

 

因此需要新增一些設定

1. niutil -create . /exports/User3 path /Volumes/Raid1/L15_1
2. niutil -create . /exports/User3 export_opts "-network 192.168.205.0 -mask 255.255.255.0"
3. niutil -createprop . /exports/User3 path /Volumes/Raid1/L15_1 
4. niutil -createprop . /exports/User3 export_opts "-network 192.168.205.0 -mask 255.255.255.0"

設定完之後檢查一下是否有正確設定:

5. niutil -read . /exports/User3                                                                                        

name: User3
path: /Volumes/Raid1/L15_1
export_opts: -network 192.168.205.0 -mask 255.255.255.0

6. reboot (重新開機,更改設定)

(記得先在/Volumes/Raid1/下新增欲分享的資料夾,這邊是以L15_1為例子)

 

===============================================================================

Server 15 client

先新增 要串聯的資料夾 以/NFS為例

1. mkdir /NFS

 

 

把遠端NFS欲mount的資料夾加入

2. mount -t nfs 192.168.205.20:/Volumes/Raid1/L15_1 /NFS

若想一開機就自動mount此NFS,則必需透過 emacs /etc/rc.d/rc.local

 



#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.


touch /var/lock/subsys/local


mount -t nfs 192.168.205.20:/Volumes/Raid1/L15_1 /NFS   <=======新增此行

鳥哥說:我們知道開機就掛載的掛載點與相關參數是寫入 /etc/fstab 中的,那 NFS 能不能寫入 /etc/fstab 當中呢?非常可惜的是, 不可以呢!為啥呢?分析一下開機的流程,我們可以發現網路的啟動是在本機掛載之後,因此當你利用 /etc/fstab 嘗試掛載 NFS 時,系統由於尚未啟動網路,所以肯定是無法掛載成功的啦!那怎辦?簡單!就寫入 /etc/rc.d/rc.local 即可!

 

 

 

創作者介紹
創作者 kendoit 的頭像
kendoit

kendoit

kendoit 發表在 痞客邦 留言(0) 人氣( 3 )