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.)