博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Unix:关于一个file在file system和disk中占用空间
阅读量:7046 次
发布时间:2019-06-28

本文共 1238 字,大约阅读时间需要 4 分钟。

參考文献:

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

转载地址:http://sxzol.baihongyu.com/

你可能感兴趣的文章
Android——计算器第一次完善
查看>>
【DDD/CQRS/微服务架构案例】在Ubuntu 14.04.4 LTS中运行WeText项目的服务端
查看>>
第四节,Linux基础命令
查看>>
使用SignalR 提高B2C商城用户体验1
查看>>
javaScript系列:js中获取时间new Date()详细介绍
查看>>
搭建Go开发及调试环境(LiteIDE + GoClipse) -- Windows篇
查看>>
[RxJS] Multicasting shortcuts: publish() and variants
查看>>
删除注释云平台JS,加快DISCUZ访问
查看>>
ThreadPoolExecutor
查看>>
JeeSite环境搭建及运行和打包(master20161117)
查看>>
Flink -- Failover
查看>>
QT笔记之解决QT5.2.0和VS2012中文乱码 以及在Qt Creator中文报错
查看>>
Hibernate 执行原始SQL语句
查看>>
在 SQL Server 2005 中配置数据库邮件
查看>>
Android 多个Fragment嵌套导致的三大BUG
查看>>
Eclipse下的Maven
查看>>
Java中使用poi导入、导出Excel
查看>>
quartus ii工程文件的分析
查看>>
Nginx %00空字节执行php漏洞
查看>>
数据包的转发流程
查看>>