Closed frostschutz closed 2 months ago
There is no problem as such - dev_size present usable volume size rounded to 'extent' after 'pvresize. You still have 4 extents (pe_count).
Theoretically lvm2 could write 'full' size - but there is no bug - 'dev_size' just needs to fit into 'physical' device .
It's confusing, if nothing else. The message "not usable X" suggests you can reduce the device size by X. But if you actually did that, you'd have killed the last PE and lost data, since it's actually in use. Now if you want to align partition size to LVM you have to do your own math instead of relying on lvm.
Well it's more confusing since there is PV VG LV. 'Extent size' is a property that is set by 'vgcreate' - so 'standalone' pvcreate can use 'all the space' since at that moment it's not known how much space will be 'used'.
So in this case - if there would be NO vg - the 'pvresize' would restore full size. However when there is known 'extent_size' with the VG - 'pvresize' will resize to the 'necessary' minimal usable size.
Basically there are some valid reasons for this logic.
It would be probably much better to disclose and how lvm2 can emit something more usable for your case.
Also you really should be using 'pvs -o+xxxxx' with more flags for easy 'parsing' - instead of getting things out of 'pvdisplay'
For 'real' physical device size - you should use 'blockdev --getsize64' or 'pvs -o+dev_size'
For some reason after
pvresize
the dev_size comes out wrong andpvdisplay
shows "not usable 1.00 MiB" even though it is in use.Create a test VG:
Use pvresize on it (17M -> 15M -> 17M):
Result:
So for some reason the dev_size is recorded as 16M but it still uses 16M in physical extents plus 1M in metadata.
pvresize -v
shows the correct dev_size 34816 sectors but then says "No change".