是否有任何理由在每次调用时都不使用use ?--sparse=always
cp
info cp
说:
‘--sparse=WHEN’ A “sparse file” contains “holes”—a sequence of zero bytes that does not occupy any physical disk blocks; the ‘read’ system call reads these as zeros. This can both save considerable disk space and increase speed, since many binary files contain lots of consecutive zero bytes. By default, ‘cp’ detects holes in input source files via a crude heuristic and makes the corresponding output file sparse as well. Only regular files may be sparse. The WHEN value can be one of the following:
...
‘always’ For each sufficiently long sequence of zero bytes in the input file, attempt to create a corresponding hole in the output file, even if the input file does not appear to be sparse. This is useful when the input file resides on a file system that does not support sparse files (for example, ‘efs’ file systems in SGI IRIX 5.3 and earlier), but the output file is on a type of file system that does support them. Holes may be created only in regular files, so if the destination file is of some other type, ‘cp’ does not even try to make it sparse.
它还说:
[...]具有以下别名,“ cp”将使用文件系统支持的最小空间量。
alias cp='cp --reflink=auto --sparse=always'
为什么没有--sparse=always
默认值?
也许仅仅是因为开发人员想要利用最少惊喜的原理,还是因为POSIX另有规定?(即使在posix中也算是cp,我忘记了)
—
cat
检查稀疏性可能会降低性能,稀疏文件可能会导致严重的文件系统碎片,并且至少存在一个使用损坏数据的实例
—
frostschutz
cp --sparse
。
通过读/写循环复制的数据(主要是非稀疏)文件涉及到数据流入和流出的内存的DMA,而寻找暗示的零的运行总是(或汽车,其中块的数量不文件匹配大小)会将数据拖到CPU缓存中,并涉及更多的CPU带宽和周期。
—
meuh's
@StephenKitt它是与--reflink兼容:
—
汤姆·黑尔
info cp
包含:with the following alias, ‘cp’ will use the minimum amount of space supported by the file system.
alias cp='cp --reflink=auto --sparse=always'
--reflink
除了不知道以外,它与... 不兼容...