Is it possible to do online resizing of guest block devices ( Or without shutdown ?)

Today I got this question,

Is it possible to resize guest block device without shutting down the guest ? Or in other way, Is it possible to do online resizing of guest block devices ?

The answer was ‘YES‘, it is possible with a switch called ‘blockresize’ of ‘virsh’ command :

Below example would illustrate this method in a simple way:

Inside guest, the second ‘disk’ has ‘512M’ Space.

Now on host we resize the LVM ( which is the backend or the underlying space for second disk of VM)  to 1 GB

An then from the host OS I do the following:

After which from the guest we recheck again and see the following.

So, we were able to do ‘online’ resizing of guest block device using ‘blockresize’ of ‘virsh’ command’.

You should have quite recent libvirt version for this support.

Additional Ref#;a=commitdiff;h=ab95da40587665063b0c8eaeae22c91003f0da1c

If your libvirt doesnot have support for online resize of guest block device, you may give a try with libguestfs, but its offline.

for complete guide on guest LVM and filesystem extenstion please refer

6 Replies to “Is it possible to do online resizing of guest block devices ( Or without shutdown ?)”

  1. Thanks for help. It worked except the last step. So, I informed VM with the new size:

    # virsh blockresize –path

    it showed me that it is succedeed:
    Block device ‘/dev/alma-srv-1/alma-backup-1’ is resized

    VM noticed the new size:

    virtio_blk virtio1: new size: 3145728000 512-byte logical blocks (1.61 TB/1.46 TiB)

    And kernel knows about new size:
    # lsblk
    vda 254:0 0 1.5T 0 disk

    # cat /sys/block/vda/size

    But fdisk, cfdisk, sfdisk, parted do not notice the new size:

    # fdisk -l /dev/vda
    Disk /dev/vda: 1073.7 GB, 1073741824000 bytes

    #cfdisk /dev/vda
    Disk Drive: /dev/vda
    Size: 1073741824000 bytes, 1073.7 GB

    What can it be? How can I update the size all partition utulities use?

    1. Hi, Can you try below commands ..

      #parted -l, fdisk -l /dev/vda ( before and after #partprobe ).

      ‘partprobe’ may not be really needed.. still a try..

  2. I wasn’t aware about virsh blockresize option. Thanks a lot for sharing the details. It seems a syntax problem in 3rd output snippet –

    # virsh blockresize –path /dev/VMDISK/lvm1 –size 1024M

    I got following when tried

    # virsh blockresize –path /dev/vg1/lv1 –size 10240M
    error: command ‘blockresize’ requires option

    Thanks a lot for such a good article !.

    Cheers ….

Leave a Reply

Your email address will not be published. Required fields are marked *