qcow2镜像文件瘦身 配置
& q5 ~7 M: a6 B+ E
2 Q. e, H7 {* d" O" F) l9 Z8 ^使用dd命令将客户机未使用的磁盘空间用0填满 % l9 D4 H. U0 }3 |; l& E
$dd if=/dev/zero of=~/junk
" D% f* V5 o& i2 n% ?: Kdd: writing to `/home/***/junk’: No space left on device
0 K1 b/ d0 a) _5 h' S而后
0 @- Q1 r; S: \& }$rm junk # j+ W2 J y$ {# |# v
关闭客户机
- Z; q! G' a! _$ E i/ ]$ G$ N# X1 x2 z& I
" ^1 Z, {' \% e
$ G1 N% C( E* K1 y9 s9 o0 F
# K6 A- d+ l% Q% {( [qemu-img check debian.qcow2
. n# j- N# C [# @ o* p t) BNo errors were found on the image.4 [( o B2 |$ L
74133/81920 = 90.49% allocated, 0.00% fragmented, 0.00% compressed clusters
! @( L! ]9 B @8 E( M' Y* l" XImage end offset: 4859428864 . I' v" ^0 H3 s/ h+ _
[root@controller src]# qemu-img convert -c -O qcow2 debian.qcow2 debian.qcow2.qcow2
% V( q" X# v8 N) P* S
' S! a N1 u1 V7 D: v) c" M" {- S+ s ]
' P1 x1 J) X4 w5 c$ l; n : B q! ^* }4 S4 l5 t) d+ d% \0 x* [
|