'lvextend -l 100%FREE' resizing to the number of free extents rather than adding them to the current size in RHEL

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL) 4, 5, 6 or 7

Issue

  • I believe it to be the case that:

    # lvextend -l 100%FREE /dev/VolGroup00/lv_root
    
  • Error

  New size given (XXX extents) not larger than existing size (XXX extents)

...will extend the logical volume lvroot to be its current size plus the current free space in the volume group.  That is not what it is attempting to do however.

  • When resizing a logical volume with the following command, it is try to resize it to the number of free extents, rather than the current size plus the number of free extents

    # lvextend -l 100%FREE <logvol path>
    

Resolution

Use the + symbol in front of X%FREE to indicate the space should be added to the current size.

# lvextend -l +100%FREE /dev/volgroup/logvol

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

2 Comments

This is surely a helpful option to use rather than figuring out how many free PE's are available & then to use that no.

Yes. Think of this as simply calculating a number from the % part and then substituting it directly into the command. The code just does exactly what you ask without considering whether or not it would be a sensible thing to do. The one concession that current versions of the code make is that, because it's working with percentages, it accepts that the number calculated might not be exact and it allows it to be adjusted up or down (according to the situation) if that's needed to make the command succeed.