Unix:关于一个file在file system和disk中占用空间

参考文献:

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值