当扩展 kvm/libvirt 磁盘时遇到“...小于相应的 PV 大小”错误时,如何正确更新容器大小?

当扩展 kvm/libvirt 磁盘时遇到“...小于相应的 PV 大小”错误时,如何正确更新容器大小?

我在 Debian buster 系统上作为 KVM/libvirt 主机工作,并按照本指南扩展了我的客户的磁盘:https://computingforgeeks.com/how-to-extend-increase-kvm-virtual-machine-disk-size/

当将 kvm/libvirt 客户机的磁盘从 50G 扩展到 200G 时,重新启动客户机后出现错误:

WARNING: Device /dev/sda5 has size of 103854080 sectors which is smaller than corresponding PV size of 418426880 sectors. Was device resized?

重启之前我做的最后一件事是在扩展 PV 之后调整 LV 的大小。

我原本希望能够调整分区大小,然后调整文件系统的大小,但事实并非如此。我猜 LVM 对其大小感到困惑。我如何让它更新不同容器(物理卷、逻辑卷、卷组、分区)的大小信息?

这是我得到的诊断输出:

 pvs
  WARNING: Device /dev/sda5 has size of 103854080 sectors which is smaller than corresponding PV size of 418426880 sectors. Was device resized?
  One or more devices used as PVs in VG cosa-cloud-vg have changed sizes.
  PV         VG            Fmt  Attr PSize    PFree
  /dev/sda5  cosa-cloud-vg lvm2 a--  <199.52g 5.00g

 vgs
  WARNING: Device /dev/sda5 has size of 103854080 sectors which is smaller than corresponding PV size of 418426880 sectors. Was device resized?
  One or more devices used as PVs in VG cosa-cloud-vg have changed sizes.
  VG            #PV #LV #SN Attr   VSize    VFree
  cosa-cloud-vg   1   2   0 wz--n- <199.52g 5.00g

lvs
  WARNING: Device /dev/sda5 has size of 103854080 sectors which is smaller than corresponding PV size of 418426880 sectors. Was device resized?
  One or more devices used as PVs in VG cosa-cloud-vg have changed sizes.
  LV     VG            Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   cosa-cloud-vg -wi------- 193.56g
  swap_1 cosa-cloud-vg -wi-a----- 980.00m

 fdisk -l
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf64fd2c9

Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1  *       2048    999423    997376  487M 83 Linux
/dev/sda2       1001470 104855551 103854082 49.5G  5 Extended
/dev/sda5       1001472 104855551 103854080 49.5G 8e Linux LVM


Disk /dev/sdb: 4 GiB, 4294967296 bytes, 8388608 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/cosa--cloud--vg-swap_1: 980 MiB, 1027604480 bytes, 2007040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


(parted) print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 419430400s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start     End         Size        Type      File system  Flags
 1      2048s     999423s     997376s     primary   ext2         boot
 2      1001470s  104855551s  103854082s  extended
 5      1001472s  104855551s  103854080s  logical                lvm

注意 fdisk 和 parted 在磁盘大小方面的差异(200G vs 215G)。不确定那是什么意思。

相关内容