[linux-lvm] Underlying physical volume resized?!

Marian Csontos mcsontos at redhat.com
Fri Nov 18 03:43:38 UTC 2016


On 11/15/2016 03:27 PM, Gionatan Danti wrote:
> Dear all,
> I have a question about a warning message LVM is showing. I am using
> CentOS 6.8 x86_64. Here is my pvs/vgs/lvs configuration:
>
> pvs:
>   PV         VG   Fmt  Attr PSize   PFree
>   /dev/sda2  vg   lvm2 a--u   9,51g    0
>   /dev/sda3  vg   lvm2 a--u 110,00g    0
>   /dev/sdb1  vg   lvm2 a--u 120,00g 4,00g
>
> vgs:
>   VG   #PV #LV #SN Attr   VSize   VFree
>   vg     3   2   0 wz--n- 239,50g 4,00g
>
> lvs:
>   LV      VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log
> Cpy%Sync Convert
>   lv_root vg   -wi-ao---- 233,56g
>   lv_swap vg   -wi-ao----   1,94g
>
> Both at kernel discovery (during boot) and when issuing lvs or other LVM
> commands I have the warning:
>
> "Device /dev/sda2 has size of 19945392 sectors which is smaller than
> corresponding PV size of 19945472 sectors. Was device resized? One or
> more devices used as PVs in VG vg have changed sizes."

Hi, the warning was added only recently - commit c0912af3 added 2016-01-22:

https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=c0912af3104cb72ea275d90b8b1d68a25a9ca48a

Were the partitions created by anaconda?
This might be an installer bug.

LVM allows overriding PV size to be larger than device size.

More about the feature here: 
https://bugzilla.redhat.com/show_bug.cgi?id=1323950

I do not think pvmove could help here, as there will be read errors on 
the device.

Deactivating swap (`swapoff /dev/$VG/$LV`)
deleting the swap LV (`lvremove $VG/$LV`)
shrinking the PV (simply running `pvresize /dev/sda2` without arguments),
recreating the swap LV (`lvcreate -n $LV -L $SIZE $VG`),
`mkswap /dev/$VG/$LV`
and `swapon /dev/$VG/$LV`
should do.

-- Marian

>
> However, my partitions where never shrunk. fdisk on /dev/sda:
>
> Disk /dev/sda: 128.8 GB, 128849018880 bytes
> 255 heads, 63 sectors/track, 15665 cylinders, total 251658240 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
> Disk identifier: 0x000a3c73
>
>    Device Boot      Start         End      Blocks   Id  System
> /dev/sda1   *        2048     1026047      512000   83  Linux
> /dev/sda2         1026048    20971439     9972696   8e  Linux LVM
> /dev/sda3        20971440   251658239   115343400   8e  Linux LVM
>
> By fdisk output, lvm is right: 20971439-1026048+1=19945392, so sda2 is
> 80 sectors (40 KB) smaller than lvm expects (19945472 sectors). I
> expanded the root volume quite a few times; however, I *never* resized
> sda2: at each expansion I took a snapshot of the disk's MBR, so I
> already checked that I did not mess with sda2 in the past.
>
> By using lvm metadata archived in /etc/lvm/archive, I think that the
> missing 80 sectors are squarely in the swap space (lv_swap, which used
> the last physical extents when lv_root was much smaller), but I am
> somewhat worried that, given some process write to these "missing" 80
> sectors, something bad can happen to the next adjacent physical extent
> (where live data are store, as it is part of lv_root now).
>
> In short:
>
> 1) can someone point me on what happen here, and why lvs only recently
> started to complain?
>
> 2) do you think my data are at risk?
>
> 3) what I can do to solve the problem? I can think of two different
> approach: a) run pvreside /dev/sda2 to shrunk the physical volume or b)
> shrunk the swap partition to be sure nobody will ever write to the last
> 80 sectors.
>
> Thanks.
>




More information about the linux-lvm mailing list