如何在solaris中使用auto mount来mount NFS

来源:岁月联盟 编辑:zhu 时间:2008-04-13
如何在solaris中使用auto mount来mount NFS内容简介:auto mount 它是属於 dynamic mount, 也就是说,当你有使用这个 mount 的目录时, 系统才会自动的帮你把这个目录mount进来. 它不同於 static mount , 是在於 static mount 是在系统开机时,mount 便进来了,而 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 进来了.

图片内容