0

I want to remove a PV from a Volume Group on a system where a large amount of data is written to the disks all the time. I can use pvmove to move all of the PV's physical extents to another PV and I did this a few times on lightly loaded systems where only a small amount of data is written to disks. In those cases when I finished moving all of the physical extents to another PV, the original PV was completely free and it could be removed from the volume group.

My concern is that on a heavily written volume when I finish pvmoving all of the physical extents, LVM will reallocate space on the currently freed PV because it is still part of the Volume Group. Is there a way to set the PV as readable, but not writable (or some kind of copy-on-write mode) so LVM won't try to write new data to the freed PV?

In other words, can I move all PE-s from a PV to another PV and remove the freed up PV from the Volume Group in an atomic operation?

2
  • Why would those extents be reused on a heavily stressed system? I dont believe that unless you are doing things at the volume level that the load on the system makes a difference to allocation.
    – davidgo
    Oct 25 '19 at 1:20
  • On "heavily stressed" I meant there are large amount of data written to the disk volumes. I'll modify the question.
    – karatedog
    Oct 25 '19 at 14:52
0

From man pvchange:

EXAMPLES
Disallow the allocation of physical extents on a PV (e.g. because of disk errors, or because it will be removed after freeing it).

pvchange -x n /dev/sdk1 

So you should do this: first pvchange -x n, then pvmove, then vgreduce, (then perhaps pvremove to wipe the label).

4
  • I admit I fail to see what would allocate PEs without any LVM command made by administration. Snapshot from cron? Self care provisionning for a container/VM creation?
    – A.B
    Oct 26 '19 at 0:16
  • PEs are allocated by writing data to the LV. If you pvmove the PEs from a whole PV, you just move the data and modify some segments in a VG but the original place remains allocatable. If you would fully write an LV, those PEs that were freed would be filled with data. (This is a corner case as the volume would be full).
    – karatedog
    Oct 26 '19 at 16:28
  • I thought PE are allocated on the PV at LV creation (and with commands altering the LV, like pvmove), not by writing data to the LV
    – A.B
    Oct 26 '19 at 19:05
  • In my experience if I pvmove a single PE from a PE segment on PV (say, I have a PE range 1000-2000 and pvmove the #1001 PE), that just moves the data that was 'inside' the PE, but leaves the PE allocatable again, it does not mark the PE as not writable, or otherwise break that contigous block of PEs.
    – karatedog
    Oct 26 '19 at 22:16

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.