17.3. 使?用? qemu-img
qemu-img 命?令?行?工?具?是? Xen 和? KVM 用?来?格?式?化?各?种?文?件?系?统?的?。?可?使?用? qemu-img 格?式?化?虚?拟?客?户?端?映?像?、?附?加?存?储?设?备?以?及?网?络?存?储?。?qemu-img 选?项?及?用?法?如?下?。?
格?式?化?并?创?建?新?映?像?或?者?设?备?
创?建?新?磁?盘?映?像?文?件?名?为? size,格?式?为? format。?
# qemu-img create [-6] [-e] [-b base_image] [-f format] filename [size]
If base_image is specified, then the image will record only the differences from base_image. No size needs to be specified in this case. base_image will never be modified unless you use the "commit" monitor command.
将?现?有?映?像?转?换?成?另?一?种?格?式?
转?换?选?项?是?将?可?识?别?格?式?转?换?为?另?一?个?映?像?格?式?。?
命?令?格?式?:
# qemu-img convert [-c] [-e] [-f format] filename [-O output_format] output_filename
convert the disk image filename to disk image output_filename using format output_format. it can be optionally encrypted ("-e" option) or compressed ("-c" option).
only the format "qcow" supports encryption or compression. the compression is read-only. it means that if a compressed sector is rewritten, then it is rewritten as uncompressed data.
加?密?法?是?使?用?非?常?安?全?的? 128 位?密?钥?的? AES 格?式?。?使?用?长?密?码?(16 个?字?符?以?上?)获?得?最?大?程?度?的?保?护?。?
当?使?用?可?增?大?的?映?像?格?式?,比?如? qcow 或? cow 时?,映?像?转?换?可?帮?助?您?获?得?较?小?的?映?像?。?在?目?的?映?像?中?可?检?测?并?压?缩?空?白?字?段?。?
获?得?映?像?信?息?
info 参?数?显?示?磁?盘?映?像?信?息?。?info 选?项?的?格?式?如?下?:
# qemu-img info [-f format] filename
给?出?磁?盘?映?像?文?件?名?信?息?。?使?用?它?可?获?得?在?磁?盘?中?保?留?空?间?大?小?,它?可?能?与?显?示?的?大?小?有?所?不?同?。?如?果?在?磁?盘?映?像?中?保?存?有? vm 快?照?,则?此?时?也?会?显?示?。?
支?持?格?式?
映?像?格?式?通?常?是?自?动?获?取?的?。?支?持?以?下?格?式?:
raw
Raw 磁?盘?映?像?格?式?(默?认?)。?这?个?格?式?的?优?点?是?可?以?简?单?、?容?易?地?导?出?到?其?它?模?拟?器?中?。?如?果?您?的?文?件?系?统?支?持?中?断?(例?如?在? Linux 中?的? ext2 或?者? ext3 以?及? Windows 中?的? NTFS),那?么?只?有?写?入?的?字?段?会?占?用?空?间?。?使?用? qemu-img info 了?解? Unix/Linux 中?映?像?或?者? ls -ls 使?用?的?实?际?大?小?。?
qcow2
QEMU 映?像?格?式?,最?万?能?的?格?式?。?使?用?它?可?获?得?较?小?映?像?(如?果?您?的?系?统?不?支?持?中?断?,例?如?在? Windows 中?,它?会?很?有?用?)、?额?外?的? AES 加?密?法?、?zlib 压?缩?以?及?对?多? VM 快?照?的?支?持?。?
qcow
旧?的? QEMU 映?像?格?式?。?只?用?于?与?旧?版?本?兼?容?。?
cow
写?入?映?像?格?式?的?用?户?模?式? Linux 副?本?。?包?含? cow 格?式?的?目?的?只?是?为?了?与?前?面?的?版?本?兼?容?。?它?无?法?在? Windows 中?使?用?。?
vmdk
VMware 3 和? 4 兼?容?映?像?格?式?。?
cloop
Linux 压?缩?回?送?映?像?,只?有?在?重?复?使?用?直?接?压?缩?的? CD-ROM 映?像?时?有?用?,比?如?在? Knoppix CD-ROM 中?。?
例如:
将img文件转化为qcow2_cow文件形式:
qemu-img convert root.img -O qcow2 kvm-centos-5.4-64-weibo_duilie_php5.2.14.qcow2_cow
反之一样。
http://hi.baidu.com/xielf301/blog/item/a189bd99a31fd894a977a4ac.html