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

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

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

    常用鏈接

    統(tǒng)計(jì)

    最新評(píng)論

    DU和DF(轉(zhuǎn))

     
    這個(gè)文檔能給你一個(gè)滿意的答復(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用于報(bào)告文件系統(tǒng)的總塊數(shù)及剩余塊數(shù),du -s /<filesystem>用于報(bào)告文件系統(tǒng)使用的塊數(shù)。但是,我們可以發(fā)現(xiàn)從df命令算出的文件系統(tǒng)使用塊數(shù)的值與通過(guò)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命令實(shí)施上的不同: du -s命令通過(guò)將指定文件系統(tǒng)中所有的目錄、符號(hào)鏈接和文件使用的塊數(shù)累加得到該文件系統(tǒng)使用的總塊數(shù);而df命令通過(guò)查看文件系統(tǒng)磁盤(pán)塊分配圖得出總塊數(shù)與剩余塊數(shù)。

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

      du命令是用戶級(jí)的程序,它不考慮Meta Data,而df命令則查看文件系統(tǒng)的磁盤(pán)分配圖并考慮Meta Data。df命令獲得真正的文件系統(tǒng)數(shù)據(jù),而du命令只查看文件系統(tǒng)的部分情況。例如,一個(gè)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

      對(duì)于AIX 4.X版本:

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

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

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

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

      41 * 8 = 328

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

      所以有344個(gè)以512字節(jié)為單位的塊分配給了這個(gè)空的文件系統(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。該值與上面得出的值一致。

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

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

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

      列出一個(gè)目錄占用的空間

      1.

      du或du -s或du -k

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

      2.

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

      3.

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

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


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


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲AV日韩综合一区尤物| 中文字幕人成无码免费视频| 亚洲AV永久无码精品放毛片| 久久噜噜噜久久亚洲va久| 吃奶摸下高潮60分钟免费视频| 在线视频精品免费| 99热这里只有精品6免费| 99久久免费国产特黄| 亚洲国产aⅴ成人精品无吗| 亚洲毛片无码专区亚洲乱| 亚洲av综合avav中文| 亚洲精品成人无限看| 国产av无码专区亚洲国产精品| 国产麻豆剧传媒精品国产免费| 69成人免费视频| h视频在线观看免费网站| 午夜精品免费在线观看| 免费在线中文日本| 黄网站免费在线观看| 精品国产免费人成网站| 一区二区三区免费视频观看| 美女视频黄a视频全免费网站一区 美女视频黄a视频全免费网站色 | 免费A级毛片av无码| a毛片视频免费观看影院| 精品人妻系列无码人妻免费视频 | 精品国产免费人成电影在线观看| 国产免费AV片在线观看| 男女一边摸一边做爽的免费视频| 一级全免费视频播放| 特黄aa级毛片免费视频播放| 污视频网站在线观看免费| 免费人成动漫在线播放r18| 免费精品视频在线| yellow免费网站| 中文字幕在线免费视频| 男女拍拍拍免费视频网站| 人人玩人人添人人澡免费| 精品无码无人网站免费视频| 91视频免费网址| 男女做羞羞的事视频免费观看无遮挡| 久久精品免费一区二区|