linux – 通过网络复制后稀疏文件显着增大(但仍然稀疏)

linux – 通过网络复制后稀疏文件显着增大(但仍然稀疏),第1张

概述尝试通过网络将稀疏VM映像文件从一个KVM管理程序复制到另一个KVM管理程序时,我看到以下行为: >稀疏文件仍然是稀疏文件 >复制的稀疏文件明显大于原始稀疏文件 资源: [root@kvm1 thin_images]# ls -lhstotal 2.6G1.4G -rw-------. 1 root root 8.0G Jul 20 11:10 centos6-8g.img1.3G -rw- 尝试通过网络将稀疏VM映像文件从一个KVM管理程序复制到另一个KVM管理程序时,我看到以下行为:

>稀疏文件仍然是稀疏文件
>复制的稀疏文件明显大于原始稀疏文件

资源:

[root@kvm1 thin_images]# ls -lhstotal 2.6G1.4G -rw-------. 1 root root 8.0G Jul 20 11:10 centos6-8g.img1.3G -rw-------. 1 root root 8.0G Jul 20 10:50 debian7-8g.img

目的地:

[root@kvm2 thin_images]# ls -lhstotal 11G4.8G -rw-------. 1 root root 8.0G Jul 20 11:10 centos6-8g.img6.2G -rw-------. 1 root root 8.0G Jul 20 10:50 debian7-8g.img

如您所见,CentOS映像的稀疏文件现在是4.8G而不是1.4G.对于Debian图像,它从1.3G增长到6.2G.

我尝试通过网络进行复制的方法包括a dirty nc-tar pipe和rsync with –sparse and –inplace options.虚拟机管理程序不在新的linux内核上使用the SEEK_HOLE functionality of bsdtar,也没有bsdtar本身.

对此行为有何解释?目标稀疏文件在通过网络复制后是否可以保持与原始稀疏文件相同的大小?

其他信息:

[root@kvm1 thin_images]# uname -alinux kvm1 2.6.32-504.23.4.el6.x86_64 #1 SMP Tue Jun 9 20:57:37 UTC 2015 x86_64 x86_64 x86_64 GNU/linux[root@kvm1 thin_images]# yum List installed rsync tar ncLoaded plugins: fastestmirror,securityLoading mirror speeds from cached hostfile * base: centos-mirror.jchost.net * extras: mirror.spro.net * updates: mirror.es.its.nyu.eduInstalled Packagesnc.x86_64                                                  1.84-22.el6                                                 @base                                   rsync.x86_64                                               3.0.6-12.el6                                                @anaconda-CentOS-201410241409.x86_64/6.6tar.x86_64                                                 2:1.23-11.el6                                               @anaconda-CentOS-201410241409.x86_64/6.6
解决方法 rsync等通常只在一定数量的字节之后稀疏,并且通常仅在块大小上(需要读取源代码,但我记得有关它的块大小),以决定使用稀疏方法的方式.因此,将复制和写入其中写入单个字节的块,从而分配块大小,而不是寻找该字节,以及寻找其余字节.在原始文件中,块大小为512字节,但传输/等. (用于优化)将是64k块大小.那么在64kb中设置的单个字节将64kb写入磁盘,而不是寻求稀疏化“阻塞”.

即使在这些映像的本地文件系统上,您也可以通过rsync看到类似的结果.

看看这些邮政转账:https://rwmj.wordpress.com/2010/10/19/tip-making-a-disk-image-sparse/和
http://blog.easter-eggs.org/index.php/post/2013/09/24/Convert-an-unsparse-vm-image-to-sparse-vm-image
您提供的链接中的建议也将适用:

> rsync –sparse local dest:// directory />使用这些工具再次使其稀疏>在所有后续运行中使用rsync –inplace>如果文件再次变得“太大”,则重新稀疏文件

总结

以上是内存溢出为你收集整理的linux – 通过网络复制后稀疏文件显着增大(但仍然稀疏)全部内容,希望文章能够帮你解决linux – 通过网络复制后稀疏文件显着增大(但仍然稀疏)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1036203.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存