大网数据广告活动
服务器运维问答

How to get Linux kernel to rescan virtio disks?

· 52CE 我爱测

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 …

问题原文

原帖链接 · MegaBrutal · CC BY-SA 4.0

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?

已采纳解答

原帖链接 · John Mahowald · CC BY-SA 4.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-10-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。