auto mount 它是屬於 dynamic mount, 也就是說,當你有使用這個 mount 的目錄
時, 系統才會自動的幫你把這個目錄mount進來.
它不同於 static mount , 是在於 static mount 是在系統開機時, 便 mount 進來
了,而且除非系統關機,或是 root 把它 unmount 掉, 不然的話,你隨時打 mount,
都可以看到它有 mount 上.
使用 auto mount 的好處是,因為它是在你有用到該目錄時才做 mount 的動作,
所以用它來 mount NFS 的話,可以不必等對方的 server 起來, 你就能開機,而且
auto mount 它有設定說,在一定時間內,如果該目錄沒被使用,則系統會自動將它
unmount 掉. 這樣又可減少因 mount NFS 而影響系統效率.
在 solaris 中,要設定 automount ,你可以去 man automount.
以下簡單說明如何設定 automount.
1. 修改 /etc/auto_master
這個檔是 automount 的主要設定檔,它里面有定義要 mount 那些目錄.
另外,它亦可以參考到另一個你自己設定的 automount 設定檔.
下面舉一個例子說明如何設定 ( auto_myconfig 是自己的設定檔)
% more /etc/auto_master
# Master map for automounter
#
+auto_master
/net -hosts -nosuid,nobrowse
/- /etc/auto_myconfig
/home auto_home -nobrowse
/xfn -xfn
% more /etc/auto_myconfig
/usr/local -rw,intr sparc:/usr/local
在 /etc/auto_myconfig 中,則是去 mount 一臺叫 sparc 它所 share 出來
/usr/local 的目錄, 并將它 mount 到自己機器的 /usr/local
ps. 如果你使用 automount 的話,在你自己的機器上,并不需要自己去建立
要 mount 的目錄, 以上面為例,你并不需要在 /usr 下建立 local 這
個目錄再做 mount. auto mount 它會自動幫你建立這個目錄,且幫你
mount 上去.
2. 改好了 auto mount 的設定檔之後,你必需重跑 autofs 才會使你修改的
auto mount 生效. 執行方法如下:
% su
% cd /etc/init.d
% autofs stop
% autofs start
也就是說, 你要以 root 的身份,先讓 aufofs 停掉, 再讓它重新 start 就可
以了.
執行完之後, 你就可以到你 mount 的目錄下打 ls 看看是否有 mount 進來了.