<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    常用鏈接

    統(tǒng)計

    最新評論

    DU和DF(轉(zhuǎn))

     
    這個文檔能給你一個滿意的答復(fù):) 
    Document Id: 26928Synopsis: du and df Differences (originally published 8/91) 
    Update date: 2001-05-13Description: du and df Differences 
    -- --- -- ----------- 

    This article explains how reporting disk usage du and reporting free disk space 
    on file systems df may show different numbers. 

    du 
    -- 

    The du user command gives the number of kilobytes contained in all files and, 
    recursively, directories within each specified directory or file (filename). 
    If filename is missing, `.' (the current directory) is used.  A file which 
    has multiple links to it is only counted once. 

    EXAMPLE: 

      system % du 

      5    ./jokes 
      33   ./squash 
      44   ./tech.papers/lpr.document 
      217  ./tech.papers/new.manager 
      401  ./tech.papers 
      144  ./memos 
      80   ./letters 
      388  ./window 
      93   ./messages 
      15   ./useful.news 
      1211 . 

    Note that the last number, 1211 is the grand total (in kilobytes) for the 
    directory. 

    df 
    -- 

    The df user command displays the following information: 

      amount of disk space occupied by currently mounted file systems 
      the amount of used and available space 
      how much of the file system's total capacity has been used 

    Used without arguments, df reports on all mounted file systems. 

    EXAMPLE: 

      system % df 

      Filesystem  kbytes  used  avail  capacity  Mounted on 
      /dev/ip0a    7445    4714 1986   70%       / 
      /dev/ip0g   42277   35291 2758   93%       /usr 

    Note: used plus avail is less than the amount of space in the file system 
    (kilobytes) because the system reserves a fraction of the space in the file 
    system to allow its allocation routines to work well.  The amount reserved is 
    typically about 10%.  (This may be adjusted using the tunefs command.  Refer to 
    the man pages on tunefs(8) for more information.)  When all the space on a file 
    system, except for this reserve, is in use, only the super-user can allocate 
    new files and data blocks to existing files.  This, however, may cause the file 
    system to be over allocated.  When a file system is over allocated in this way, 
    df may report that the file system is more than 100% utilized. 

    If arguments to df are disk partitions (for example, /dev/ip0as or path names), 
    df produces a report on the file system containing the named file.  Thus, df 
    shows the amount of space on the file system containing the current directory. 

    Problem Definition 
    ------- ---------- 

    This section gives the technical explanation of why du and df sometimes report 
    different totals of disk space usage. 

    When a program that is running in the background writes to a file while the 
    process is running, the file to which this process is writing is deleted. 
    Running df and du shows a discrepancy in the amount of disk space usage.  The 
    df command shows a higher value. 

    Explanation Summary 
    ----------- ------- 

    When you open a file, you get a pointer.  Subsequent writes to this file 
    references this file pointer.  The write call does not check to see if the file 
    is there or not.  It just writes to the specified number of characters starting 
    at a predetermined location.  Regardless of whether the file exist or not, disk 
    blocks are used by the write operation. 

    The df command reports the number of disk blocks used while du goes through the 
    file structure and and reports the number of blocks used by each directory.  As 
    far as du is concerned, the file used by the process does not exist, so it does 
    not report blocks used by this phantom file.  But df keeps track of disk blocks 
    used, and it reports the blocks used by this phantom file.
     du和df命令都被用于獲得文件系統(tǒng)大小的信息:df用于報告文件系統(tǒng)的總塊數(shù)及剩余塊數(shù),du -s /<filesystem>用于報告文件系統(tǒng)使用的塊數(shù)。但是,我們可以發(fā)現(xiàn)從df命令算出的文件系統(tǒng)使用塊數(shù)的值與通過du命令得出的值是不一致的。如下例:
      # du -s /tmp 返回如下值:
      ---12920 /tmp
      而 df /tmp返回如下值:
      Filesystem --512-blocks-- Free --%Used --Iused-- %Iused --Mounted on
      /dev/hd3 --------57344 --42208--- 26% ----391 ------4% --/tmp

      從上面的值我們可以算出<total from df> - <Free from df> = <used block count>: 57344 - 42208 = 15136. 而15136大于12920。該值差異的存在是由于du與df命令實施上的不同: du -s命令通過將指定文件系統(tǒng)中所有的目錄、符號鏈接和文件使用的塊數(shù)累加得到該文件系統(tǒng)使用的總塊數(shù);而df命令通過查看文件系統(tǒng)磁盤塊分配圖得出總塊數(shù)與剩余塊數(shù)。

      文件系統(tǒng)分配其中的一些磁盤塊用來記錄它自身的一些數(shù)據(jù),如i節(jié)點,磁盤分布圖,間接塊,超級塊等。這些數(shù)據(jù)對大多數(shù)用戶級的程序來說是不可見的,通常稱為Meta Data。

      du命令是用戶級的程序,它不考慮Meta Data,而df命令則查看文件系統(tǒng)的磁盤分配圖并考慮Meta Data。df命令獲得真正的文件系統(tǒng)數(shù)據(jù),而du命令只查看文件系統(tǒng)的部分情況。例如,一個frag=4096 并且 nbpi=4096的空的大小為4MB的日志文件系統(tǒng)中Meta Data的分配情況如下:

      1 4k block for the LVM

      2 4k super blocks

      2 4k blocks for disk maps

      2 4k blocks for inode maps

      2 4k blocks for .indirect

      32 4k blocks for inodes

      -------------------------

      41 4k blocks for meta data on an empty 4MB file system

      對于AIX 4.X版本:

      執(zhí)行 du /foo返回的結(jié)果如下:

      ----8 -------/foo/lost+found

      ----16 ------/foo

      要使du命令輸出的結(jié)果與df命令輸出的結(jié)果匹配,我們必須要加上Meta Data。首先,將41個4k的塊轉(zhuǎn)換為以512字節(jié)為單位的值:

      41 * 8 = 328

      328(meta data) + 16(from du) = 344

      所以有344個以512字節(jié)為單位的塊分配給了這個空的文件系統(tǒng)。

      而使用 df /foo命令我們可以得到下面的結(jié)果:

      Filesystem --512-blocks --Free --%Used --Iused---%Iused --Mounted on

      /dev/lv01 ------8192 -----7848 -----5% -----16 -----2% ----/foo

      從中我們可以得到該文件系統(tǒng)使用的塊數(shù):8192(total blocks) - 7848(free blocks) = 344。該值與上面得出的值一致。

      上面的換算方法對于空的文件系統(tǒng)很容易實現(xiàn),但是對于非空的文件系統(tǒng),由于Meta Data中文件間接塊的大小不定,因此較難實現(xiàn)。所以我們不需要查看du 與 df返回的值的匹配關(guān)系,而只需要了解du -s命令返回的值反映了分配給文件及目錄的磁盤塊數(shù),而df命令則反映了文件系統(tǒng)的實際分配情況。df命令反映的實際情況包含了用戶數(shù)據(jù)(文件及目錄)和Meta Data。

      另一個表現(xiàn)出du與df命令不同之處的例子如下:

      如果用戶刪除了一個正在運行的應(yīng)用所打開的某個目錄下的文件,則du命令返回的值顯示出減去了該文件后的目錄的大小。但df命令并不顯示減去該文件后的大小。直到該運行的應(yīng)用關(guān)閉了這個打開的文件,df返回的值才顯示出減去了該文件后的文件系統(tǒng)的使用情況。

      列出一個目錄占用的空間

      1.

      du或du -s或du -k

      du -S | sort -n 可以迅速發(fā)現(xiàn)那個目錄是最大的。

      2.

      用df可以看到已安裝的文件系統(tǒng)的空間大小及剩余空間大小。

      3.

      quota -v查看用戶的磁盤空間信息,如果你用quota限制了用戶空間大小的話。

    posted on 2010-08-26 16:27 九寶 閱讀(155) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 国产无遮挡裸体免费视频在线观看| 亚洲一区二区三区播放在线| 免费看的黄色大片| 大地资源网高清在线观看免费| 亚洲日韩一区二区一无码| 精品久久亚洲中文无码| 亚洲成a人片在线网站| 亚洲AV天天做在线观看| 亚洲无线码一区二区三区| 久久久久亚洲AV无码专区网站| 青青草国产免费久久久下载| 成人免费激情视频| 亚洲熟妇成人精品一区| jlzzjlzz亚洲jzjzjz| 亚洲欧美日韩中文字幕一区二区三区| 亚洲AV无码乱码在线观看裸奔 | 亚洲AV日韩AV永久无码绿巨人| 中文字幕第一页亚洲| 亚洲av女电影网| 亚洲人成网址在线观看| 亚洲a级在线观看| 国产精品亚洲а∨天堂2021 | 日韩一级免费视频| 亚洲永久无码3D动漫一区| 亚洲精品电影在线| 国产精品亚洲一区二区在线观看 | 亚洲国产精品尤物YW在线观看| 亚洲午夜精品久久久久久浪潮| 亚洲色爱图小说专区| 亚洲理论在线观看| 欧洲精品码一区二区三区免费看| 99免费精品视频| 国产午夜无码视频免费网站| 亚洲国产一区二区a毛片| 亚洲精品无码少妇30P| 在线观看免费视频一区| 国产乱码免费卡1卡二卡3卡| 国产国拍亚洲精品福利| 中文字幕在线日亚洲9| 99免费在线观看视频| 免费在线观看a级毛片|