I want to shrink my LVM physical volume and use this free space to create another partition for another OS.

I resized my root and home logical volumes using lvresize and now I'm trying to use pvresize, but I get the following error:

/dev/sda2: cannot resize to xxxxx extents as later ones are allocated.

This PV's free space is allocated between two logical volumes and I think that's the reason that can't shrink the partition.

The output for pvs -v --segments /dev/sda2 is:

PV         VG        Fmt  Attr PSize   PFree   Start SSize LV      Start Type   PE Ranges             
  /dev/sda2  volgroup0 lvm2 a--  446.64g 148.00g     0  7680 lv_root     0 linear /dev/sda2:0-7679      
  /dev/sda2  volgroup0 lvm2 a--  446.64g 148.00g  7680 51712 lv_home     0 linear /dev/sda2:7680-59391  
  /dev/sda2  volgroup0 lvm2 a--  446.64g 148.00g 59392 37888             0 free                         
  /dev/sda2  volgroup0 lvm2 a--  446.64g 148.00g 97280 17060 lv_root  7680 linear /dev/sda2:97280-114339

The free space is allocated between the segments 59392 and 97279. I know that pmove can move the free space to another segment, but I honestly don't know how to use it and I'm afraid of corrupting my data.

Could anyone please help me on this? Thanks!

  • There is always a risk, in particular in case of power failure or so. When manipulating disk blocks, back up your data first. Suggestions without guarantee that it works: Perhaps a simple pvmove /dev/sda2 does the job, or use the --alloc anywhere option as in the examples section of the manual page. Mar 10, 2021 at 2:27
  • @berndbausch tried this solution but it didn't worked Mar 10, 2021 at 22:49

1 Answer 1


pvmove moves segments, not free space. You need to move this range /dev/sda2:97280-114339 to start at segment 59392 Those are 17061 segments.

According to this you should:

# pvmove --alloc anywhere /dev/sda2:97280-114339 /dev/sda2:59392-76453

Then resize PV, then partition, and then enjoy your free space. While LVM tries to avoid shooting yourself in the foot, this is a risky operation. If you have any data that would cause you any trouble if it goes missing, backup it first since you will most likely destroy it. Also, you can create a linux VM and test this commands until you feel confident in it.

  • Thank you so much for your help, that worked! I'm not familiar with the concept of segments, do you know where I can learn more about this? Mar 10, 2021 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.