RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1323950 - Resizing PV to be larger than the containing partition is allowed without force.
Summary: Resizing PV to be larger than the containing partition is allowed without force.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: lvm2
Version: 7.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: LVM and device-mapper development team
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-05 07:20 UTC by Marian Csontos
Modified: 2021-09-08 20:29 UTC (History)
10 users (show)

Fixed In Version: lvm2-2.02.160-1.el7
Doc Type: Bug Fix
Doc Text:
There's a new warning message issued if PV size recorded in LVM metadata is more than actual device size and the PV is part of a VG. This situation may happen in case --setphysicalvolume is used to override actual device size during pvcreate or if the device size changed after creating a PV.
Clone Of:
Environment:
Last Closed: 2016-11-04 04:19:47 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:1445 0 normal SHIPPED_LIVE lvm2 bug fix and enhancement update 2016-11-03 13:46:41 UTC

Description Marian Csontos 2016-04-05 07:20:50 UTC
Description of problem:
Resizing PV to be larger than the partition it is on is allowed without force.

Buggy automation tools or user scripts may call this by mistake and cause problems.

This should work only with force and only after asking user to proceed (or with `--yes` option).

Version-Release number of selected component (if applicable):
lvm2-2.02.130-1.fc23.x86_64 (Tested on F23, there is no reason to believe it does not happen on RHEL7 with the same version of LVM.)

How reproducible:
100%

Steps to Reproduce:
PV=/dev/sdXN
- create a PV on 256M large partition.
- resize it:
[root@r-fixresizepv ~]# pvresize --setphysicalvolumesize 300M $PV

Actual results:
[root@r-fixresizepv ~]# pvresize --setphysicalvolumesize 300M $PV
  WARNING: /dev/sda1: Overriding real size. You could lose data.
  Physical volume "/dev/sda1" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

The PV is resized, no error is indicated anywhere in the `pvs` or `vgs` output.

Expected results:
This should not be allowed without asking user.
User should be warned about the inconsistency when running next lvm commands.

Additional info:

Comment 2 Peter Rajnoha 2016-06-02 14:17:08 UTC
We do have a warning now which checks the PV size against size stored in metadata:

# pvcreate --setphysicalvolumesize 300M /dev/sda
  WARNING: /dev/sda: Overriding real size. You could lose data.
  Physical volume "/dev/sda" successfully created.

# vgcreate vg /dev/sda
  WARNING: Device /dev/sda has size of 262144 sectors which is smaller than corresponding PV size of 614400 sectors. Was device resized?
  Volume group "vg" successfully created

# pvs
  WARNING: Device /dev/sda has size of 262144 sectors which is smaller than corresponding PV size of 614400 sectors. Was device resized?
  One or more devices used as PVs in VG vg have changed sizes.
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/sda   vg     lvm2 a--  296.00m 296.00m

# vgs
  WARNING: Device /dev/sda has size of 262144 sectors which is smaller than corresponding PV size of 614400 sectors. Was device resized?
  One or more devices used as PVs in VG vg have changed sizes.
...

# lvs
  WARNING: Device /dev/sda has size of 262144 sectors which is smaller than corresponding PV size of 614400 sectors. Was device resized?
  One or more devices used as PVs in VG vg have changed sizes.
...

===

However, we don't show this warning if PV is not yet part of any VG - that's because there's no risk of losing data yet, the risk is only if we're trying to allocate LVs on such PVs:

# pvcreate --setphysicalvolumesize 300M /dev/sda
  Incorrect metadata area header checksum on /dev/sda at offset 4096
  WARNING: /dev/sda: Overriding real size. You could lose data.
  Physical volume "/dev/sda" successfully created.

# pvs
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/sda          lvm2 ---  300.00m 300.00m


===

These checks are there since lvm2 v 2.02.141:

https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=d090d6574e455625ad4e2a1a6f3d93f5c663b097
https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=1f5dfb7369600c169ecd2c78e0cd079ad1442548
https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=c0912af3104cb72ea275d90b8b1d68a25a9ca48a
https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=136fd8f2f642c82b132ded4b9a95b05e822e9117
https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=bc8f8ac0facc610c3252eb9af592b9c63a935ce2

===

As for the requirement for the --force - well, the --setphysicalvolumesize option itself is considered relatively dangerous and even the man page says:

 --setphysicalvolumesize size
              Overrides the automatically-detected size of the PV.  Use with care.

So if someone uses that for whatever reason, he probably knows what he's doing. But yes, maybe we should add Y/N question to make sure.

There's also pvresize --setphysicalvolumesize to consider...

Comment 3 Peter Rajnoha 2016-07-12 13:55:57 UTC
(In reply to Peter Rajnoha from comment #2)
> As for the requirement for the --force - well, the --setphysicalvolumesize
> option itself is considered relatively dangerous and even the man page says:
> 
>  --setphysicalvolumesize size
>               Overrides the automatically-detected size of the PV.  Use with
> care.
> 
> So if someone uses that for whatever reason, he probably knows what he's
> doing. But yes, maybe we should add Y/N question to make sure.

Still, someone may already use this in existing scripts and this options is more for power users than for common everyday use. If people use such PV in a VG, we do have a warning now.

Also, that option is there for ages and we haven't had any reports from our customers related to use of this option - so let's just go with the warning that gets issued in lvm commands if there's a PV where size is more than its device's real size.

Comment 4 Roman Bednář 2016-07-13 10:01:39 UTC
Adding QA ack for 7.3.

Comment 6 Corey Marthaler 2016-09-09 20:49:34 UTC
Marking verified in the latest rpms. Like mentioned in comment #3, there is no prompt now, just additional warning messages when resizing PVs larger than their actual partition size.


# RHEL7.2 lvm2-2.02.130-5

[root@host-128 ~]# pvcreate /dev/sda1
  Physical volume "/dev/sda1" successfully created

[root@host-128 ~]# vgcreate vg /dev/sda1
  Volume group "vg" successfully created

[root@host-128 ~]# pvresize --setphysicalvolumesize 30G /dev/sda1
  WARNING: /dev/sda1: Overriding real size. You could lose data.
  Physical volume "/dev/sda1" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

[root@host-128 ~]# pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sda1  vg   lvm2 a--  30.00g 30.00g

[root@host-128 ~]# vgs
  VG   #PV #LV #SN Attr   VSize  VFree 
  vg     1   0   0 wz--n- 30.00g 30.00g

[root@host-128 ~]# pvresize --setphysicalvolumesize 40G /dev/sda1
  WARNING: /dev/sda1: Overriding real size. You could lose data.
  Physical volume "/dev/sda1" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized



# RHEL7.3 lvm2-2.02.165-1

[root@host-118 ~]# pvcreate /dev/sda1
  Physical volume "/dev/sda1" successfully created.

[root@host-118 ~]# vgcreate vg /dev/sda1
  Volume group "vg" successfully created

[root@host-118 ~]# pvresize --setphysicalvolumesize 30G /dev/sda1
  WARNING: /dev/sda1: Overriding real size. You could lose data.
  Physical volume "/dev/sda1" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

[root@host-118 ~]# pvs
  WARNING: Device /dev/sda1 has size of 41929587 sectors which is smaller than corresponding PV size of 62912512 sectors. Was device resized?
  One or more devices used as PVs in VG vg have changed sizes.
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sda1  vg   lvm2 a--  30.00g 30.00g

[root@host-118 ~]# vgs
  WARNING: Device /dev/sda1 has size of 41929587 sectors which is smaller than corresponding PV size of 62912512 sectors. Was device resized?
  One or more devices used as PVs in VG vg have changed sizes.
  VG   #PV #LV #SN Attr   VSize  VFree 
  vg     1   0   0 wz--n- 30.00g 30.00g

[root@host-118 ~]# pvresize --setphysicalvolumesize 40G /dev/sda1
  WARNING: Device /dev/sda1 has size of 41929587 sectors which is smaller than corresponding PV size of 62912512 sectors. Was device resized?
  One or more devices used as PVs in VG vg have changed sizes.
  WARNING: /dev/sda1: Overriding real size. You could lose data.
  Physical volume "/dev/sda1" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

Comment 8 errata-xmlrpc 2016-11-04 04:19:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-1445.html


Note You need to log in before you can comment on or make changes to this bug.