当试图从一个KVMpipe理程序将稀疏的VM映像文件复制到另一个networking时,我看到以下行为:
资源:
[root@kvm1 thin_images]# ls -lhs total 2.6G 1.4G -rw-------. 1 root root 8.0G Jul 20 11:10 centos6-8g.img 1.3G -rw-------. 1 root root 8.0G Jul 20 10:50 debian7-8g.img
目的地:
[root@kvm2 thin_images]# ls -lhs total 11G 4.8G -rw-------. 1 root root 8.0G Jul 20 11:10 centos6-8g.img 6.2G -rw-------. 1 root root 8.0G Jul 20 10:50 debian7-8g.img
正如你所看到的,CentOS映像的稀疏文件现在是4.8G而不是1.4G。 对于Debian镜像,它从1.3G发展到了6.2G。
我试过在networking上复制的方法包括一个脏的NC-tarpipe道和带有–sparse和–inplace选项的rsync 。 pipe理程序没有足够新的Linux内核来使用bsdtar的SEEK_HOLEfunction ,也没有bsdtar本身。
对此行为的任何解释? 目标稀疏文件在通过networking复制之后是否可以保持原始稀疏文件的大小?
其他信息:
[root@kvm1 thin_images]# uname -a Linux 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 nc Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile * base: centos-mirror.jchost.net * extras: mirror.spro.net * updates: mirror.es.its.nyu.edu Installed Packages nc.x86_64 1.84-22.el6 @base rsync.x86_64 3.0.6-12.el6 @anaconda-CentOS-201410241409.x86_64/6.6 tar.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然后,您提供的链接中的build议将适用: