「稀疏文件」 @20210212
稀疏文件是什么?
看维基百科的介绍吧:「Wikipedia/Sparse file」
稀疏文件常用操作
如何判断是稀疏文件?
使用find /var/log -type f -printf "%S\t%p\n"判断文件是否为稀疏文件。
或者使用stat -c '%b*%B-%s' -- "$file"命令。
最左边一列(%S)显示的值是(BLOCK-SIZE * st_blocks / st_size),在稀疏文件的情况下通常小于1.0[1]。
「archlinux/Sparse file」
「Finding sparse files?」
如何复制稀疏文件?
方法还是由很多的,性能可能会有所差异,使用场景以有些不一样的地方:「What is fastest way to copy a sparse file? What method results in the smallest file?」
可以使用cp、dd、cpio、rsync、virt-sparsify等命令,其中virt-sparsify是用于虚拟机迁移,当时是为了迁移虚拟机镜像文件,才有所涉猎。
这里不再深入,有需要的时候再研究,详细内容参考各个命令的手册。
稀疏文件的实际大小
「So what is the size of that file? Sparse Files on Linux」
# TODO 关于稀疏文件的实际大小
注释说明
[1]. How to find all the sparse files in Linux
参考文献
Wikipedia/Sparse file
What is fastest way to copy a sparse file? What method results in the smallest file?