qcow2镜像文件瘦身 配置/ x/ ~0 Z) z0 [( y z% e
5 L+ R( f0 Y& h4 r7 O
使用dd命令将客户机未使用的磁盘空间用0填满
9 I! h- x9 H& {$dd if=/dev/zero of=~/junk
7 u# g7 F5 K( r! I) Pdd: writing to `/home/***/junk’: No space left on device , n% y. G0 O1 J5 G
而后 3 G6 w+ X1 F% X2 A
$rm junk " o& U( u$ O7 D0 h
关闭客户机
% M9 Z+ a# s. `9 [0 q
2 k6 g- x* P Q6 \* ~7 @ ; K$ B4 n4 Q$ }9 F
! |$ ~$ ]+ `( x
W( d+ }# Z% X8 zqemu-img check debian.qcow2
: H/ A. A/ b; s" `& R6 c8 Z bNo errors were found on the image.
! d7 b# [5 e6 d/ j74133/81920 = 90.49% allocated, 0.00% fragmented, 0.00% compressed clusters
+ C2 s5 t7 X! p% U9 w& q' L0 EImage end offset: 4859428864 4 ?3 p! ?% f) u1 o2 k
[root@controller src]# qemu-img convert -c -O qcow2 debian.qcow2 debian.qcow2.qcow2" R! A S# w) I* H" K
/ C' Z+ [/ ?' D, F( m2 _. L
' l( L9 m) k; U( J/ L& [" `6 i+ i( x* }. }' S% z3 ]" W& D
) I' V! F( _& e6 T/ W% _ |