qcow2 image disk os used size is very less how to reduce its size for disk.

In case of KVM virtualization in your LAB, You may experience space crunch though you are not using much space actually inside VM. But VM disk on your host storage will take much space as per allocated.
Here i am telling you process to how reduce it and fit to actuall disk usage. This is kind of thin provisioning .

in my case let see-
[root@nuc1 images]# qemu-img info toweramx.qcow2
image: toweramx.qcow2
file format: qcow2
virtual size: 30G (32212254720 bytes)
disk size: 30G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true
Her you can see virtual size is 30 Gb means i have allocated this to VM.
but disksize is 1.4 GB only which is actually i used on VM. But you can see both size shows as 30GB .
Now run qemu-img command to get it fix

$ qemu-img convert -O qcow2 toweramx.qcow2 test1.qcow2
$ rm -rf toweramx.qcow2
$ mv test1.qcow2 toweramx.qcow2



[root@nuc1 images]# qemu-img info toweramx.qcow2
image: toweramx.qcow2
file format: qcow2
virtual size: 30G (32212254720 bytes)
disk size: 1.4G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true


Done ! enjoy

Comments

Popular posts from this blog

Running web ssh client on port 443 /80 with nginx as reverse proxy

Running cockpit behind nginx reverse proxy with nginx ssl and cockpit non ssl

Setup VOD streaming server with nginx using RTMP on Ubuntu 18.04