I have 2 logical volumes lv1 and lv2 which are part of the same volume group vg0. I have to remove 2 physical disks that are associated to the vg0. Can I do a lvremove, vgreduce and pvremove on lv1 without affecting the data on lv2.


Yes, you can lvremove LV1 without affecting data on LV2. That's why they are separate LVs.

Before vgreducing a PV out of the VG, you should check that the PV is reported as completely free by either the pvs or the pvdisplay command. If not, and you have other PVs in the VG with free space available, you can use the pvmove command to move the data out of the PV you wish to remove and onto one (or more, if necessary) of the PVs you're planning to keep - while the LVs are mounted and in use. (That's one of the things that makes LVM awesome when you need to avoid downtime.)

The simplest way to use pvmove is just to specify the name of the PV you wish to make empty. It is smart enough to look at other PVs in the same VG and find free space for any data it needs to move. Of course, you can also specify the destination PV - or multiple destination PV if the data you need to move won't fit onto any single PV you wish to keep. pvmove will first move data from the source PV to the first destination PV until that destination becomes full, and then continue on to the next specified destination PV.

Once the PV is completely free (pvs reports PFree = PSize for it, or pvdisplay <PV device name> reports "Allocated PE" = 0), you're free to vgreduce it out of the VG.

After that, you're free to remove the PV from the system. If you're planning to reuse the disk without repartitioning or otherwise overwriting it, you can use pvremove to remove the LVM PV header from the disk, but any other way of that makes the system no longer see the LVM PV header will work just as well. (At that point, all the non-historical LVM metadata referring to that PV is on that PV itself. If that partition or disk vanishes, LVM will understand just fine that the PV is gone.)

  • To add on if the logical volume is forced to be created using a specific disk like this lvcreate -L 100 -n mylv /dev/myvg /dev/sda, pvmove is not required. I was able to remove the LV May 4 '18 at 7:47

If the space from the partitions on those disks is being used by lv2 then it will be affected when you vgreduce and pvremove.

The best thing to do is to back up the data, lvremove both, vgreduce, pvremove, and then recreate the physical volumes and lv2 and then restore the data.

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.