



Make sure the size of the newly created disk is 30GB: $ virt-filesystems -long -parts -blkdevs -h -a centos8.qcow2Ĭreate a new virtual disk image using qemu-img command Sample output: Formatting 'centos8.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off preallocation=metadata compression_type=zlib size=32212254720 lazy_refcounts=off refcount_bits=16 The above command will rename current disk image called centos8.qcow2 to .Ĭreate a new disk image with same name and with size 30GB using command: $ qemu-img create -f qcow2 -o preallocation=metadata centos8.qcow2 30G Before resizing disk image, power off the Virtual machine and take the backup of the original disk image. Also, Virt-resize should not be used on live virtual machines. Virt-resize cannot resize disk images in-place. Expand the second partition /dev/sda2 to fill the remaining space.increase the size of the first partition /dev/sda1 from 1.0GB to 1.5GB,.increase the total disk image size from 20 GB to 30 GB,.To print the partition details and their size of a disk image, run: $ virt-filesystems -long -parts -blkdevs -h -a centos8.qcow2ĭisplay current partitions and their sizes using virt-filesystems command in LinuxĪs you can see in the above output, my disk image has only two partitions, namely /dev/sda1 with size 1 GB and /dev/sda2 with 19GB. Replace centos8 with your VM name in the above command.Īfter locating the disk image you want to resize, inspect the partition details inside this disk image. You can use virsh dumpxml command to locate the disk image that you want to resize. I have stored this mage in my current working directory. Expand or extend KVM virtual machine disk size in Linuxįor the purpose of this guide, I will be using CentOS 8 virtual machine disk image named centos8.qcow2. Now let us see how to expand virtual machine disk size using virt-resize command.

So if you're on Fedora 34, install guestfs-tools package like below: $ sudo dnf install guestfs-tools In Fedora 34, guestfs-tools package provides virt-resize tool. To install libguestfs-tools package on Fedora, RHEL and its clones, run: $ sudo dnf install libguestfs-tools To install libguestfs-tools package on Debian, Ubuntu and its derivatives, run: $ sudo apt install libguestfs-tools Virt-resize is the part of the libguestfs-tools package. And then we copy the source image to the destination image and finally resize it. To expand a Virtual machine's disk size, we first create a larger disk image than the source image. The guest systems should be turned off before resizing their disk images. Please note that virt-resize the live machines. We can also delete the partitions inside the virtual disk with virt-resize command. Using virt-resize, we can either increase or decrease the size of a virtual machine's disk. Virt-resize is a command line tool to resize a virtual machine disk.
