{"id":412,"date":"2012-10-09T11:03:55","date_gmt":"2012-10-09T11:03:55","guid":{"rendered":""},"modified":"2013-02-07T12:10:29","modified_gmt":"2013-02-07T04:10:29","slug":"%5b%e8%bd%ac%e8%bd%bd%5d-qcow2%e3%80%81raw%e3%80%81vmdk%e7%ad%89%e9%95%9c%e5%83%8f%e6%a0%bc%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/dingxuan.info\/wp\/?p=412","title":{"rendered":"[\u8f6c\u8f7d] qcow2\u3001raw\u3001vmdk\u7b49\u955c\u50cf\u683c\u5f0f"},"content":{"rendered":"<p>\u4e00\u76f4\u7ea0\u7ed3\u5728\u505a\u865a\u62df\u5316\u4f7f\u7528\u4ec0\u4e48\u955c\u50cf\u683c\u5f0f\uff0c\u521a\u521a\u5f00\u59cb\u7528\u4e86raw\u7684file\uff0c\u540e\u6765\u53d1\u73b0LVM\u7684\u5f88\u591a\u7279\u6027\u5bf9\u4e8e\u865a\u62df\u5316\u8fd8\u662f\u6709\u6bd4\u8f83\u7406\u60f3\u7684\u80fd\u529b\uff0c\u800c\u4e14\u6027\u80fd\u4e5f\u5f88\u4e0d\u9519\u5c31\u7528\u4e86LVM\u3002\u540e\u6765\u88abVMware\u9a97\u4e86\u8dd1\u53bb\u641eEsxi\u63a5\u89e6\u4e86VMDK\uff0c\u6700\u8fd1\u7814\u7a76openstack\u53d1\u73b0\u4e86qcow2\u683c\u5f0f\uff0c\u8c8c\u4f3c\u73b0\u5728\u5f88\u6d41\u884c\u5440\u3002\u4e5f\u8bf4\u4e0d\u4e0a\u5206\u6790\u8fd9\u4e9b\u955c\u50cf\u683c\u5f0f\u7684\u80fd\u529b\uff0c\u5c31\u7b80\u5355\u8bf4\u8bf4\u81ea\u5df1\u7684\u4e00\u4e9b\u4f7f\u7528\u5fc3\u5f97\u3002<br \/><br \/>\u76ee\u524d\u4e3b\u8981\u6709\u90a3\u4e9b\u683c\u5f0f\u6765\u4f5c\u4e3a\u865a\u62df\u673a\u7684\u955c\u50cf\uff1a<!--more--><br \/><span style=\"font-size: 14px\">raw<\/span>\n<br \/>(default) the raw format is a plain binary image of the disc image, and is very portable. On filesystems that support sparse files, images in this format only use the space actually used by the data recorded in them.<br \/>\u8001\u724c\u7684\u683c\u5f0f\u4e86\uff0c\u7528\u4e00\u4e2a\u5b57\u6765\u8bf4\u5c31\u662f\u88f8\uff0c\u4e5f\u5c31\u662f\u8d64\u88f8\u88f8\uff0c\u4f60\u968f\u4fbfdd\u4e00\u4e2afile\u5c31\u6a21\u62df\u4e86\u4e00\u4e2araw\u683c\u5f0f\u7684\u955c\u50cf\u3002\u7531\u4e8e\u88f8\u7684\u5f7b\u5e95\uff0c\u6027\u80fd\u4e0a\u6765\u8bf4\u7684\u8bdd\u8fd8\u662f\u4e0d\u9519\u7684\u3002\u76ee\u524d\u6765\u770b\uff0cKVM\u548cXEN\u9ed8\u8ba4\u7684\u683c\u5f0f\u597d\u50cf\u8fd8\u662f\u8fd9\u4e2a\u683c\u5f0f\u3002\u56e0\u4e3a\u5176\u539f\u59cb\uff0c\u6709\u5f88\u591a\u539f\u751f\u7684\u7279\u6027\uff0c\u4f8b\u5982\u76f4\u63a5\u6302\u8f7d\u4e5f\u662f\u4e00\u4ef6\u7b80\u5355\u7684\u4e8b\u60c5\u3002<br \/>\u88f8\u7684\u597d\u5904\u8fd8\u6709\u5c31\u662f\u7b80\u5355\uff0c\u652f\u6301\u8f6c\u6362\u6210\u5176\u5b83\u683c\u5f0f\u7684\u865a\u62df\u673a\u955c\u50cf\u5bf9\u88f8\u9732\u7684\u5b83\u6765\u8bf4\u8fd8\u662f\u5f88\u7b80\u5355\u7684\uff08\u5982\u679c\u5176\u5b83\u683c\u5f0f\u9700\u8981\u8f6c\u6362\uff0c\u6709\u65f6\u5019\u8fd8\u662f\u9700\u8981\u5b83\u505a\u4e3a\u4e2d\u95f4\u683c\u5f0f\uff09\uff0c\u7a7a\u95f4\u4f7f\u7528\u6765\u770b\uff0c\u8fd9\u4e2a\u5f88\u50cf\u78c1\u76d8\uff0c\u4f7f\u7528\u591a\u5c11\u5c31\u662f\u591a\u5c11\uff08du -h\u770b\u5230\u7684\u5927\u5c0f\u5c31\u662f\u4f7f\u7528\u5927\u5c0f\uff09\uff0c\u4f46\u5982\u679c\u4f60\u8981\u628a\u6574\u5757\u78c1\u76d8\u90fd\u62ff\u8d70\u7684\u8bdd\u5f97\u5168\u76d8\u62ff\u4e86\uff08copy\u955c\u50cf\u7684\u65f6\u5019\uff09\uff0c\u4f1a\u6bd4\u8f83\u6d88\u8017\u7f51\u7edc\u5e26\u5bbd\u548cI\/O\u3002\u63a5\u4e0b\u6765\u8fd8\u6709\u4e2a\u6709\u8da3\u7684\u95ee\u9898\uff0c\u5982\u679c\u90a3\u5929\u4f60\u7684\u786c\u76d8\u7528\u7740\u7528\u7740\u4e0d\u591f\u7528\u4e86\uff0c\u4f60\u548b\u529e\uff0c\u5728\u4e70\u4e00\u5757\u76d8\u3002\u4f46raw\u683c\u5f0f\u7684\u5c31\u6bd4\u8f83\u7280\u5229\u4e86\uff0c\u53ef\u4ee5\u5728\u539f\u6765\u7684\u76d8\u4e0a\u8ffd\u52a0\u7a7a\u95f4\uff1a<br \/>dd if=\/dev\/zero of=zeros.raw bs=1024k count=4096\uff08\u5148\u521b\u5efa4G\u7684\u7a7a\u95f4\uff09<br \/>cat foresight.img zeros.raw &gt; new-foresight.img\uff08\u8ffd\u52a0\u5230\u539f\u6709\u7684\u955c\u50cf\u4e4b\u540e\uff09<br \/>\u5f53\u7136\uff0c\u597d\u4e1c\u897f\u662f\u5439\u51fa\u6765\u7684\uff0c\u8c01\u7528\u8c01\u77e5\u9053\uff0c\u8fd8\u662f\u6709\u633a\u591a\u95ee\u9898\u7684\u3002\u7531\u4e8e\u539f\u751f\u7684\u88f8\u683c\u5f0f\uff0c\u4e0d\u652f\u6301snapshot\u4e5f\u662f\u5f88\u6b63\u5e38\u7684\u3002\u4f20\u8bf4\u6709\u670b\u53cb\u7528\u7248\u672c\u7ba1\u7406\u8f6f\u4ef6\u5bf9raw\u683c\u5f0f\u7684\u6587\u4ef6\u505a\u7248\u672c\u7ba1\u7406\u4ece\u800c\u8fbe\u5230snapshot\u7684\u80fd\u529b\uff0c\u4f30\u8ba1\u53ef\u884c\uff0c\u4f46\u6ca1\u8bd5\u8fc7\uff0c\u8fd9\u91cc\u4e5f\u4e0d\u5984\u52a0\u8bc4\u8bba\u3002\u4f46\u5982\u679c\u4f60\u4f7f\u7528LVM\u7684\u88f8\u8bbe\u5907\uff0c\u90a3\u5c31\u53e6\u5f53\u522b\u8bba\u3002\u8bf4\u5230LVM\u8fd8\u662f\u5341\u5206\u7684\u7280\u5229\u7684\uff0c\u5f53\u5e74\u7528LVM\u505a\u865a\u62df\u673a\u7684\u955c\u50cf\uff0c\u90a3\u6027\u80fd\u6760\u6760\u7684\u3002\u800c\u4e14\u73b0\u5728\u597d\u591a\u5144\u5f1f\u7528\u865a\u62df\u5316\u90fd\u91c7\u7528LVM\u6765\u505a\u7684\u3002\u5728LVM\u4e0a\u505a\u4e86\u5f88\u591a\u7684\u4f18\u5316\uff0c\u56fd\u5916\u542c\u8bf4\u4e5f\u6709\u670b\u53cb\u5728LVM\u589e\u91cf\u5907\u4efd\u65b9\u9762\u505a\u4e86\u5f88\u591a\u7684\u5de5\u4f5c\u3002\u76ee\u524d\u6765LVM\u7684snapshot\u3001\u6027\u80fd\u3001\u53ef\u6269\u5c55\u6027\u65b9\u9762\u90fd\u8fd8\u662f\u6709\u76f8\u5f53\u7684\u6548\u679c\u7684\u3002\u76ee\u524d\u6765\u770b\u7684\u8bdd\uff0c\u5907\u4efd\u7684\u8bdd\u4e5f\u95ee\u9898\u4e0d\u5927\u3002\u5c31\u662f\u5728\u865a\u62df\u673a\u8fc1\u79fb\u65b9\u9762\u8fd8\u662f\u6709\u5f88\u5927\u7684\u9650\u5236\u3002\u4f46\u76ee\u524d\u865a\u62df\u5316\u7684\u73b0\u72b6\u6765\u770b\uff0c\u771f\u6b63\u9700\u8981\u70ed\u8fc1\u79fb\u7684\u60c5\u51b5\u76ee\u524d\u9700\u6c42\u8fd8\u4e0d\u662f\u662f\u5426\u7684\u5f3a\u70c8\u3002\u867d\u7136\u4f7f\u7528LVM\u505a\u865a\u62df\u673a\u955c\u50cf\u7684\u76f8\u5173\u516c\u5f00\u8d44\u6599\u6bd4\u8f83\u5c11\uff0c\u4f46\u76ee\u524d\u6765\u770b\u727a\u7272\u4e00\u70b9\u7075\u6d3b\u6027\uff0c\u6362\u53d6\u6027\u80fd\u548c\u4fbf\u4e8e\u7ba1\u7406\u8fd8\u662f\u4e0d\u9519\u7684\u9009\u62e9\u3002<br \/><br \/>\u5bf9\u4e8eLVM\u76f8\u5173\u7684\u7279\u6027\u53ca\u4f7f\u7528\u53ef\u4ee5\u53c2\u8003\u5982\u4e0b\u94fe\u63a5\uff1a<br \/><br \/><a href=\"http:\/\/www.ibm.com\/developerworks\/linux\/library\/l-lvm2\/index.html\">http:\/\/www.ibm.com\/developerworks\/linux\/library\/l-lvm2\/index.html<\/a><br \/><br \/><span style=\"font-size: 14px\">cow<\/span>\n<br \/>copy-on-write format, supported for historical reasons only and not available to QEMU on Windows<br \/>\u66fe\u7ecfqemu\u7684\u5199\u65f6\u62f7\u8d1d\u7684\u955c\u50cf\u683c\u5f0f\uff0c\u76ee\u524d\u7531\u4e8e\u5386\u53f2\u9057\u7559\u539f\u56e0\u4e0d\u652f\u6301\u7a97\u53e3\u6a21\u5f0f\u3002\u4ece\u67d0\u79cd\u610f\u4e49\u4e0a\u6765\u8bf4\u662f\u4e2a\u5f03\u5a74\uff0c\u8fd8\u6ca1\u5f97\u5b83\u6210\u719f\u5c31\u6b7b\u5728\u8179\u4e2d\uff0c\u540e\u6765\u88abqcow\u683c\u5f0f\u6240\u53d6\u4ee3\u3002<br \/><br \/><span style=\"font-size: 14px\">qcow<\/span>\n<br \/>the old QEMU copy-on-write format, supported for historical reasons and superseded by qcow2<br \/><br \/>\u4e00\u4ee3\u7684qemu\u7684cow\u683c\u5f0f\uff0c\u521a\u521a\u51fa\u73b0\u7684\u65f6\u5019\u6709\u6bd4\u8f83\u597d\u7684\u7279\u6027\uff0c\u4f46\u5176\u6027\u80fd\u548craw\u683c\u5f0f\u5bf9\u6bd4\u8fd8\u662f\u6709\u5f88\u5927\u7684\u5dee\u8ddd\uff0c\u76ee\u524d\u5df2\u7ecf\u88ab\u65b0\u7248\u672c\u7684qcow2\u53d6\u4ee3\u3002\u5176\u6027\u80fd\u53ef\u4ee5\u67e5\u770b\u5982\u4e0b\u94fe\u63a5\uff1a<br \/><a href=\"http:\/\/www.linux-kvm.org\/page\/Qcow2\">http:\/\/www.linux-kvm.org\/page\/Qcow2<\/a><br \/><br \/><span style=\"font-size: 14px\">qcow2<\/span>\n<br \/>QEMU copy-on-write format with a range of special features, including the ability to take multiple snapshots, smaller images on filesystems that don\u2019t support sparse files, optional AES encryption, and optional zlib compression<br \/>\u73b0\u5728\u6bd4\u8f83\u4e3b\u6d41\u7684\u4e00\u79cd\u865a\u62df\u5316\u955c\u50cf\u683c\u5f0f\uff0c\u7ecf\u8fc7\u4e00\u4ee3\u7684\u4f18\u5316\uff0c\u76ee\u524dqcow2\u7684\u6027\u80fd\u4e0a\u63a5\u8fd1raw\u88f8\u683c\u5f0f\u7684\u6027\u80fd\uff0c\u8fd9\u4e2a\u4e5f\u7b97\u662fredhat\u7684\u5b98\u65b9\u6e20\u9053\u4e86\uff0c\u54c8\u54c8\uff0c\u5e0c\u671b\u6709\u670b\u53cb\u80fd\u62cd\u4ed6\u4eec\u7816\uff1a<br \/><br \/><a href=\"https:\/\/fedoraproject.org\/wiki\/Features\/KVM_qcow2_Performance\">https:\/\/fedoraproject.org\/wiki\/Features\/KVM_qcow2_Performance<\/a><br \/><br \/>\u5bf9\u4e8eqcow2\u7684\u683c\u5f0f\uff0c\u51e0\u70b9\u8fd8\u662f\u6bd4\u8f83\u7a81\u51fa\u7684\uff0cqcow2\u7684snapshot\uff0c\u53ef\u4ee5\u5728\u955c\u50cf\u4e0a\u505aN\u591a\u4e2a\u5feb\u7167\uff1a<br \/><br \/>\u66f4\u5c0f\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u5373\u4f7f\u662f\u4e0d\u652f\u6301holes\u7684\u6587\u4ef6\u7cfb\u7edf\u4e5f\u53ef\u4ee5\uff08\u8fd9\u4e0bdu -h\u548cls -lh\u770b\u5230\u7684\u5c31\u4e00\u6837\u4e86\uff09<br \/>Copy-on-write support, where the image only represents changes made to an underlying disk image\uff08\u8fd9\u4e2a\u7279\u6027SUN ZFS\u8868\u73b0\u7684\u6dcb\u6f13\u5c3d\u81f4\uff09<br \/>\u652f\u6301\u591a\u4e2asnapshot\uff0c\u5bf9\u5386\u53f2snapshot\u8fdb\u884c\u7ba1\u7406<br \/>\u652f\u6301zlib\u7684\u78c1\u76d8\u538b\u7f29<br \/>\u652f\u6301AES\u7684\u52a0\u5bc6<br \/><br \/><span style=\"font-size: 14px\">vmdk<\/span>\n<br \/> <br \/>VMware 3 &amp; 4, or 6 image format, for exchanging images with that product<br \/>VMware\u7684\u683c\u5f0f\uff0c\u8fd9\u4e2a\u683c\u5f0f\u8bf4\u7684\u86cb\u75bc\u4e00\u70b9\u5c31\u6709\u70b9\u725bX\uff0c\u539f\u672cVMware\u5c31\u662f\u505a\u865a\u62df\u5316\u8d77\u5bb6\uff0c\u81ea\u5df1\u505a\u4e86\u4e00\u4e2a\u96c6\u7fa4\u7684VMDK\u7684pool\uff0c\u505a\u4e86\u81ea\u5df1\u7684\u865a\u62df\u673a\u955c\u50cf\u683c\u5f0f\u3002\u53c8\u62c9\u7740\u4e00\u4e9b\u516c\u53f8\u641e\u4e86\u4e00\u4e2aOVF\u7684\u7edf\u4e00\u5c01\u5305\u3002\u4ece\u6027\u80fd\u548c\u529f\u80fd\u4e0a\u6765\u8bf4\uff0cvmdk\u5e94\u8be5\u7b97\u6700\u51fa\u8272\u7684\uff0c\u7531\u4e8evmdk\u7ed3\u5408\u4e86VMware\u7684\u5f88\u591a\u80fd\u529b\uff0c\u76ee\u524d\u6765\u770b\uff0cKVM\u548cXEN\u4f7f\u7528\u8fd9\u79cd\u683c\u5f0f\u7684\u60c5\u51b5\u4e0d\u662f\u592a\u591a\u3002\u4f46\u5c31VMware\u7684Esxi\u6765\u770b\uff0c\u5b83\u7684\u7a33\u5b9a\u6027\u548c\u5404\u65b9\u9762\u7684\u80fd\u529b\u8fd8\u662f\u53ef\u5708\u53ef\u70b9\u3002<br \/><br \/><span style=\"font-size: 14px\">vdi<\/span>\n<br \/>VirtualBox 1.1 compatible image format, for exchanging images with VirtualBox.<br \/>SUN\u6536\u8d2d\u4e86VirtualBox\uff0cOracle\u53c8\u6536\u8d2d\u4e86SUN\uff0c\u8fd9\u4e48\u8bf4\u5462\uff0cvdi\u4e5f\u7b97\u865a\u62df\u5316\u8fd9\u65b9\u9762\u7684\u4e00\u6735\u5947\u8469\uff0c\u53ef\u60dc\u7684\u662f\u5165\u4e3b\u7684\u4e24\u5bb6\u516c\u53f8\u3002SUN\u592a\u4e13\u6ce8\u4e8e\u6280\u672f\uff08\u53ef\u4ee5\u8bf4\u662fIT\u6280\u672f\u6700\u524d\u7aef\u4e5f\u4e0d\u4e3a\u8fc7\uff09\uff0cOracle\u53c8\u662f\u5f00\u6e90\u6740\u624b\uff08mysql\u7684\u6ca1\u843d\uff09\u3002\u5355\u7eaf\u4ece\u80fd\u529b\u4e0a\u6765\u8bf4vdi\u5728VirtualBox\u4e0a\u7684\u8868\u73b0\u8fd8\u662f\u4e0d\u9519\u7684\u3002\u4e5f\u662f\u4e0d\u9519\u7684workstation\u7ea7\u522b\u7684\u4ea7\u54c1\u3002<br \/><br \/>\u8bf4\u4e86\u8fd9\u4e48\u591a\u865a\u62df\u673a\u955c\u50cf\u683c\u5f0f\uff0c\u8fd9\u4e48\u591a\u865a\u62df\u5316\uff0c\u505a\u4e91\u8ba1\u7b97\u7684\u4f24\u4e0d\u8d77\u5440\uff0c\u5f97\u4e3a\u957f\u671f\u53d1\u5c55\u8003\u8651\uff0c\u4e5f\u6709\u670b\u53cb\u5bf9\u955c\u50cf\u7684\u8f6c\u6362\u505a\u4e86\u5f88\u591a\u4e8b\u60c5\uff0c\u7b80\u5355\u770b\u770b\u51e0\u79cd\u955c\u50cf\u7684\u8f6c\u5316\uff1a<br \/><br \/>VMDK\u2013&gt;qcow2:<br \/><br \/>kevin@kevin:~# qemu-img convert -f vmdk -O qcow2 SLES11SP1-single.vmdk SLES11SP1-single.img<br \/><br \/><a href=\"http:\/\/www.ibm.com\/developerworks\/cn\/linux\/l-cn-mgrtvm3\/index.html\">http:\/\/www.ibm.com\/developerworks\/cn\/linux\/l-cn-mgrtvm3\/index.html<\/a><br \/><br \/>qcow2\u2013&gt;raw:<br \/><br \/>kevin@kevin:~$ qemu-img convert -O qcow2 image-raw.raw image-raw-converted.qcow<br \/><br \/>\u539f\u6587\u94fe\u63a5 <a href=\"http:\/\/www.prajnagarden.com\/?p=248#comment-643\">http:\/\/www.prajnagarden.com\/?p=248#comment-643<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u4e00\u76f4\u7ea0\u7ed3\u5728\u505a\u865a\u62df\u5316\u4f7f\u7528\u4ec0\u4e48\u955c\u50cf\u683c\u5f0f\uff0c\u521a\u521a\u5f00\u59cb\u7528\u4e86raw\u7684file\uff0c\u540e\u6765\u53d1\u73b0LVM\u7684\u5f88\u591a\u7279\u6027\u5bf9\u4e8e\u865a\u62df\u5316\u8fd8\u662f\u6709\u6bd4\u8f83 &hellip; <a href=\"https:\/\/dingxuan.info\/wp\/?p=412\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">[\u8f6c\u8f7d] qcow2\u3001raw\u3001vmdk\u7b49\u955c\u50cf\u683c\u5f0f<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[117],"tags":[78,112],"class_list":["post-412","post","type-post","status-publish","format-standard","hentry","category-network","tag-linux","tag-vm"],"_links":{"self":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=412"}],"version-history":[{"count":0,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/412\/revisions"}],"wp:attachment":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}