3

I have a virtio disk mounted to a KVM guest, backed by an LVM logical volume. I increased the size of the logical volume with lvresize on the KVM host machine.

Then I had to issue virsh pool-refresh to make the KVM host aware of the volume size change. Now if I check the volume in virt-manager, I see the correct disk size. But the guest OS still sees the disk by its old size no matter what.

How can I force the Linux kernel to rescan virtio disks without rebooting the guest?

The other solutions I found were not specific to virtio and they didn't work. Like echo "- - -" > /sys/class/scsi_host/host0/scan should work for SCSI disks, but not virtio. Another tip, echo 1 > /sys/block/vda/device/rescan doesn't work because the rescan file doesn't exist.

So do you know about any virtio specific tip to have my virtio disk rescanned?

2
  • Won't that echo command create the rescan file? Might that be the point?
    – tsc_chazz
    Oct 2, 2021 at 0:43
  • @tsc_chazz No, I got a "Permission denied" message when I tried to create it, despite running the command as root. Generally you're not supposed to create files under /proc or /sys, they're virtual file systems where files are mapped to kernel settings.
    – MegaBrutal
    Oct 3, 2021 at 20:20

1 Answer 1

5

In addition to resizing the LV on the host, tell the running guest about it: virsh blockresize <domain> vda

As a paravirtualized driver, virtio does not pretend to be SCSI anymore, rescan hints will not work. As soon as the guest is aware if it, the volume will be larger.

While not useful in this case, a more complete SCSI scan script for Linux is rescan-scsi-bus.sh from the sg3_utils package.

2
  • 1
    Thanks, it worked! I did see blockresize, but since it requires a size argument, I thought it actually resizes the backing storage media and I didn't know how it treats LVs. But it turns out the size argument doesn't really matter when the backing media is an LV, it just notifies the guest about the actual size of the LV, doesn't attempt to resize or anything. (I experimented this by supplying various size parameters, you only live once... The guest always got the correct LV size.)
    – MegaBrutal
    Oct 3, 2021 at 20:05
  • I used the following command (size argument doesn't really matter in case the backing storage is an LVM LV): ``` root@vmhost:~# virsh blockresize Ubuntu_Focal vda 32G Block device 'vda' is resized ``` Upon success, the following messages appear in the guest's kernel ring buffer: ``` [8126307.835588] virtio_blk virtio2: [vda] new size: 67108864 512-byte logical blocks (34.4 GB/32.0 GiB) [8126307.835600] vda: detected capacity change from 17179869184 to 34359738368 ```
    – MegaBrutal
    Oct 3, 2021 at 20:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .