參考文獻:
Harley Hahns:Guide to Unix and Linux。 Chap 24
——》首先要有的關鍵概念:the amount of "disk space" used by a file is not the same as the amount of data in the file.
——》其次,了解在file system和disk(or other storage medium)中都存在各自的最小空間單元:file system中叫“block”;disk中叫“allocation unit”。
這兩個最小空間單元關系:The size of "allocation unit" depends on the filesystem and the storage device。
比方參考文獻作者計算機中,filesystem的最小占用單元block為1K Bytes,而disk allocation units 為8K Bytes。是以,有一個檔案含有1B的data,則在filesystem中占用1個block(1K),在disk中占用8K的disk space
******************************************************************************
于是以下的問題:怎樣detemine size of block? 怎樣determine size of allocation unit?
——size of allocation units:
*先建立一個非常小的檔案
*再用ls -l file檢視這個檔案含有的實際data有多少(Byte為機關)。顯示在時間前面
*再用du -h file檢視how much "disk space" the file takes up
這查出來的disk space就是你的disk中最小占用單元的大小。我的計算機上查出是4K
——size of block in filesystem:
思路是通過在管理者權限下用dumpe2fs指令檢視在filesystem中存在的一個block:SUPERBLOCK的性質。檢視它的Block size來确定在filesystem中一個block有多大
*先用df指令來find out the name of the special file that represents the filesystem, 如/dev/hda1
*再用su取得superuser的權限
*在superuser的權限在使用dumpe2fs,并用grep指令搜集“Block size”資訊:dumpe2fs /dev/hda1 | grep "Block size"
這查出來的Block size就是在你的file system中一個block的最小占用空間,我的計算機上查出是1024