backup2007

          導航

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          統計

          公告

          @import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);


          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          mount and umount [quote from ChinaUnix]

          Moduel 4   Performing Mounts and Umounts
           
              Note – While system administrators typically use the /usr/sbin/mount
          command, the system boot scripts use the /sbin/mount command.
           
               介紹/etc/vfstab文件:
           
                  /etc/vfstab列出系統啟動時自動mount的文件, 除/etc/mnttab和/var/run之外;
                  /etc/vfstab文件分出七個區域:
                      device to mount    被mount的設備和偽設備
                      device to fsck     The raw or character device e.g. /dev/rdsk下的
                                          對于偽設備如:/proc 或 fd 這項可寫  -  
                      mount point        mount 的路徑
                      FS type            文件系統類型
                      fsck pass          指示在系統啟動時是否fsck檢測;0不檢1表示fsck為系統正常啟動運行
                                          大于1時表示把此設備加入fsck運行列表,fsck可同時檢測8個設備,
                                          mountall命令忽略此項
                      mount at boot       yes 要求啟動時自動mount,no 則不
                      
              Note – For / (root), /usr, and /var (if it is a separate file system) file
          systems, the mount at boot field value is specified as no. The kernel
          mounts these file systems as part of the boot sequence before the
          mountall command is run. The mount command explicitly mounts the
          file systems / (root) and /usr as specified in the
          /etc/rcS.d/S30rootusr.sh script and the /var file system as specified
          in the /etc/rcS.d/S70buildmnttab script.
           
                      mount options        A comma-separated list of options passed to the
                                          mount command. A dash (-) indicates the use of
                                          default mount options.
           
           
              介紹/etc/mnttab文件:
                  此文件是一個只讀文件,當mount一項時,會在此文件中入一條,umount后也會在此文件中刪除相應項;
           
                  包括五項區域:
           
                      mount point    掛接點    
                      Device Name    設備名,塊設備是文件系統的物理名稱;
                      Mount Options              文件系統上生效的掛載選項列表  
                      dev=number                主從設備號
                      Date and time mounted     mount的日期時間
           
           
              使用mount
                  
                  mount /dev/dsk/c#d#t#s# /mountpoint 
                      不加參數時,使用以下默認屬性:
           
                      read/write     Indicates whether reads and writes are allowed on
                                      the file system.
                      setuid         Permits the execution of setuid programs in the
                                      file system.
                      intr/nointr     Allows and forbids keyboard interrupts to kill a
                                      process that is waiting for an operation on a locked
                                      file system.
                      nologging       Indicates that logging is not enabled for the ufs file
                                      system.
                      largefiles      Allows for the creation of files larger than 2 Gbytes.
                                      A file system mounted with this option can contain
                                      files larger than 2 Gbytes.
                      xattr           Supports extended attributes not found in
                                      standard UNIX attributes.
                      onerror=action     Specifies the action that the ufs file system should
                                          take to recover from an internal inconsistency on a
                                          file system. An action can be specified as:
                                      panic—Causes a forced system shutdown. This is
                                              the default.
                                      lock — Applies a file system lock to the file
                                              system.
                                      umount — Forcibly unmounts the file system.
          ------------------------------------------------------------------------------
          Note – Due to file system overhead, the largest file size that can be created
          is approximately 866 Gbytes.
          ------------------------------------------------------------------------------
           
              使用mount命令的option
                  Some options used to mount local file systems include: ro, nosetuid,
          noatime, nolargefiles, and logging.
           
          格式:    mount -o option,option,... device_name mount_point
              
                  # mount -o ro /dev/dsk/c0t0d0s6 /usr        -------設成只讀
                  下面是使用多個參數,設成只讀以及不允許執行setuid進程,但并不限制生成setuid
                  # mount -o ro,nosuid /dev/dsk/c0t0d0s7 /export/home
                  為提高磁盤訪問性能,文件系統訪問頻繁,最后訪問時間并不計較的可以
                  # mount -o noatime /dev/dsk/c0t0d0s7 /export/home
                  防止成生超過2G的文件,
                  # mount -o nolargefiles /dev/dsk/c0t0d0s7 /export/home
                  如果文件系統已經存在超過2G的大文件,mount會挫敗,如果想成功mount,則必須刪除相關大文件,
                  并且刪除后必須用fsck來更新超級塊的信息,如果一次運行fsck還不能成功mount則必須用fsck
                  來清除超級塊的信息;
           
                  使UFS文件系統寫日志;
                  # mount -o logging /dev/dsk/c0t0d0s7 /export/home
                  
                  存放日志文件的大小,大約是每1G分配1M的大小,最大不超過64M字節;
                  當UFS日志達其最大時,它就開始將事務記錄到文件系統中。文件系統被卸載時,整個UFS日志
                  都被清空,所有事務都被寫入文件系統。 
                  UFS日志有兩個好處。一,它文件系統的不一致性,也就不再需要長時間運行fsck掃描。
                  二,可以跳過fsck掃描,這就減少了系統在被以非正常的關閉方法關閉時,重啟的時間,
           
              使用mountall命令:
                  mountall -l 只mount本地的所有文件系統;
                  mountall命令讀取/etc/vfstab文件內容,當device to fsck 項大于0時,fsck會檢測文件系統是否完好,以致于安全掛接.當系統文件壞掉,fsck會試圖修復,mountall會mount其它掛接點,和device to fsck 項等于0的掛接點.
           
              mount一個新的文件系統:
                  八步:
                  1.把硬盤放入服務器,
                  2.重啟或devfsadm讓系統識別硬盤;
                  3.format把硬盤分區;
                  4.newfs在磁盤slice上生成新的文件系統;
                  5.在/目錄下用mkdir 生成一個新的掛接點;
                  6.mount文件系統到掛接點;
                  7.用mount命令查看是否mount成功;
                  8.修改/etc/vfstab文件,讓系統下次重啟時自動加載;
           
              mount不同類型的文件系統:
                  
                  如果mount時沒有以mount -F fstype指明的話,mount會以ufs來作為默認的類型,mount根據設備名, 塊名,或掛接點來判斷文件類型;
           
                  mount 不能從/etc/vfstab的fs entry來判斷,會以/etc/default/fs file 或
          /etc/dfs/fstypes來決定文件的掛接類型,如果是本地文件系統則是/etc/default/fs 文件中一行
          LOCAL=ufs  來確定掛接類型;
                  如果是遠程文件系統,則從/etc/dfs/fstypes第一行來確定
          nfs NFS Utilities
          autofs AUTOFS Utilities
          cachefs CACHEFS Utilities
                  
               Using the fstyp Command來查看文件類型:
           
                  # fstyp /dev/rdsk/c0t0d0s7
                  ufs
              指定一下hsfs文件系統:
                  當volume manage停止時,用hsfs來指定一個cdrom
                  # mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom
              指定一個pcfs文件系統:
                  當卷管理停止時,掛接一個駐留在diskette(軟盤)的文件系統
                  
                  # mkdir /pcfs
                  # mount -F pcfs /dev/diskette /pcfs
           
           
              執行umount命令:
                  提示:在umount文件系統前,都是先從/etc/mnttab文件種刪除相應行;
           
                  從掛接點刪除:
                  #umount /export/home
                  從邏輯硬件文件名刪除:
                  # umount /dev/dsk/c0t0d0s7
           
              執行umountall命令:
                  /usr/sbin/umountall命令會在系統關閉或在命令輸入umountall時讀取/etc/mnttab文件,然后umount
              vfstab文件中除/ (root), /usr, /proc, /dev/fd, /var,/var/run, and /tmp.之外所有行;
                  
                  umount所有文件系統:
                  #umountall 
                  umount所有本地的文件系統:
                  #umountall -l
           
              umountall狀態為busy的系統:
                  
                  以下四種情況,文件系統都會顯示:umount: file_system_name busy
           
                  1 A program is accessing a file or directory in the file system
                  2 A user is accessing a directory or file in the file system
                  3 A program has a file open in that file system
                  4 The file is being shared
           
                  有兩種方法解決:
                  (1) 使用fuser命令來確認掛接點有那些進程在訪問,然后殺掉
                  (2) 用umount -f 強制umount;
           
                  用fuser命令的四步:
                  1.確認掛接點有那些進程需要殺掉
                  #fuser -cu /mount_point 
                  2.向進程發出SIGKILL信號:
                  #fuser -ck /mount_point
                  3.確認看是否還有進程在訪問掛接點
                  #fuser -c /mount_point
                  4.umount掛接點
                  #umount /mount_point
           
                  umount -f 丟失數據,僵死進程,但比較適合遠程共享時,遠程沒有響應. 
           

          posted on 2007-09-02 13:40 backup2007 閱讀(377) 評論(0)  編輯  收藏 所屬分類: Linux

          主站蜘蛛池模板: 阳春市| 安国市| 屯留县| 邢台县| 家居| 长武县| 哈尔滨市| 乌兰察布市| 磐安县| 措勤县| 南宫市| 江都市| 高青县| 东乌珠穆沁旗| 夏邑县| 宿松县| 深圳市| 浏阳市| 双柏县| 鄂托克前旗| 西乌珠穆沁旗| 讷河市| 渭源县| 新兴县| 蓬莱市| 收藏| 乐昌市| 鄂尔多斯市| 梁河县| 五原县| 卢氏县| 三河市| 江陵县| 交口县| 上饶市| 北海市| 察雅县| 西乡县| 昂仁县| 灵武市| 三都|