dir*_*obs 7 linux filesystems sparse-files files fallocate-command
我完全理解这--dig-holes
会就地创建一个稀疏文件。也就是说,如果文件有孔--dig-holes
选项会删除这些孔:
让我们以一种非常简化的方式来看待它,假设我们有一个名为 non-sparse 的巨大文件:
非稀疏:
aaaaaaaaaaaaaaaaaaaaaaaaaaaa
\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00
bbbbbbbbbbbbbbbbbbbbbbbbbbbb
\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00
cccccccccccccccccccccccccccc
Run Code Online (Sandbox Code Playgroud)
非稀疏中有许多零,假设交错零以千兆字节为单位。fallocate --dig-holes
取消分配可用于零(空洞)的空间,其中实际文件大小保持不变(保留)。
现在,--punch-hole
它到底有什么作用?我看了手册页,还是不明白:
-p, --punch-hole
Deallocates space (i.e., creates a hole) in the byte range
starting at offset and continuing for length bytes. Within
the specified range, partial filesystem blocks are zeroed,
and whole filesystem blocks are removed from the file.
After a successful call, subsequent reads from this range
will return zeroes.
Run Code Online (Sandbox Code Playgroud)
挖洞,--dig-hole
好像是那个选项的反面,怎么挖洞跟挖洞不一样?!帮助!我们需要一个逻辑学家:)。
这两个选项的命名在语言上是同义词,这可能会造成混淆。
--dig-holes
和--punch-holes
操作上有什么区别(请不要在逻辑上或语言上!)?
Ste*_*itt 11
--dig-holes
不会更改文件的内容,这在读取文件时确定:它只是标识可以用孔替换的零的运行。
--punch-hole
使用--offset
和--length
参数在文件中打一个洞,不管文件在该偏移处包含什么:即使文件在那里包含非零,它也能工作,但文件的内容因此而改变。考虑到您的示例文件,运行fallocate --punch-hole --offset 2 --length 10
将a
用零替换十个字符,从第二个字符开始。
归档时间: |
|
查看次数: |
2520 次 |
最近记录: |