Score:0

How to properly update container sizes when extending kvm/libvirt disk when running into "... smaller then corresponding PV size" error?

us flag

I work on a Debian buster system as a KVM/libvirt host and followed this guide to extend the disk of my guest: https://computingforgeeks.com/how-to-extend-increase-kvm-virtual-machine-disk-size/ .

When extending the disk of a kvm/libvirt guest from 50G to 200G, after rebooting the guest I get the error:

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

The last thing I did before the reboot was to resize the LV, after extending the PV.

I would have expected to be able to resize the partition and then the filesystem, but I am not. I guess the LVM is confused about its size. How can I get it to update the size info of the different containers (physical volume, logical volume, volume group, partion)?

this is the diagnostic output i get:

 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

Note the discrepancy between fdisk and parted regarding the disk size (200G vs 215G). Not sure what that means.

Michael Hampton avatar
cz flag
Is your backup current? You are dangerously close to losing all your data. Back everything up now before attempting to fix this problem. You were meant to resize the disk partition(s) first, before the LVM PV and everything else. You can still do that, but again, you really should verify you have a backup first.
Andreas Schuldei avatar
us flag
I could copy the qcow2 file to some save location, right? Or do I have a better option for a backup than that? @MichaelHampton
Michael Hampton avatar
cz flag
You can do that before you resized the PV, VG and LV out of sequence!
Andreas Schuldei avatar
us flag
Ok, then I hope we get it right without losing the data.
Andreas Schuldei avatar
us flag
so I should resize /dev/sda5 to 200G now?
Michael Hampton avatar
cz flag
You'll have to resize sda2 first!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.