How To Remove LVM Physical Volume From Volume Group?

Home » CentOS » How To Remove LVM Physical Volume From Volume Group?
CentOS 9 Comments

Hi. I have a volume group (let’s say) vg_data. It consists from /dev/sdd5
sdd6
sdd7
I added sdc5

Now I want to remove (free) sdd7 and you is to for RAID partition.

What are the commands (ordered) I need to perform? I failed to find clear howto.

vg-data has only one partition, total size is over 1TB, free space is about 500GB so there is a plenty or room.

9 thoughts on - How To Remove LVM Physical Volume From Volume Group?

  • Fidsk -l (you will see sdd5, sdd6 and sdd7)
    Pvdisplay (to make sure the Allocated PE on /dev/sdd7
    Vgreduce vg_data /dev/sdd7
    Pvremove /dev/sdd7

    (before you run vgreduce you need to move all data from sdd7 to new dic

    —–Original Message—

  • The doc is recommend you do pvremove first and then run vgreduce. But you will get error something like “…you need to remove from volume group first before delete the physical volume” (the message makes sense for me. Need to removing from volume group first then removing the physical one)

    While ago I run “vgrreduce” first and then do “pvremove”. It worked fine for me.

    —–Original Message—

  • I myself always thought you would pvmove, then vgreduce, and then pvremove. Unless you also had to resize the lv first

  • If you need to move data out from sdd7 to new location. You need to pvmove /dev/new_disc first Then vgreduce and pvremove

    However, before do pvmove you need pvcreate /dev/new_disc vgextend vg_data/new_disc pvmove /dev/new_disc

    —–Original Message—

  • As like many time before, as soon as Isent the e-mail with a question, a lightbulb went off in my mind.

    1. Unmount filesystem (I only have one in the group) on Logical Volume.
    2. Resize Logical Volume since I stretched it before (did not know how all that goes). I resized it to well over the size of sdd7. I used LVM
    GUI for filesystem+LV resize in one go.

    Now:
    3. pvmove to move away all allocated extents
    4. vgreduce

    I hope those last too go without a problem. Will report back.

  • It turned out that new partition, sdc5 is smaller then sdd7, so pvmove failed.

    But then I checked the LVM GUI and solved the problem. I opened Physical volumes, chose sdd7 and clicked on “Migrate Extents…..” which offered to redistribute all of the Extents automatically to the rest of the PV’s.

    At the moment I am waiting for migration to complete, but then removal of PV should be simple. I think I will use wonderful LVM GUI again, and I will not allow anyone to tell me how DE/GUI on a server is bad thing. ;)

  • There are lots of rumors regarding the existence of a GUI. Sometimes it’s a bit weird to use very low level tools when you have tools that will give you much more power in your hands.

    But again some prefer to know what they do in the lowest levels and others just want to do the thing while they know it works and was designed to work. When the two collide ( works vs power) lots prefer to have only works
    (what seems to be a very bad assumption).

    Many times you don’t need GUI for servers to operate and sometimes the existence of a GUI slow the server down and lowering the performance of the system.

    So taking couple things into account most admins agree that a GUI should not be needed when you know how to operate the machine using the CLI tools. If you feel the need to use GUI tools have it your way and have a nice smile to your CLI friends which struggle every once in a while how to do things in a way they prefer and note that not all admins are alike.

    (I am still looking for a GUI utils to operate GlusterFS which seems to be there in RH storage systems)

    Regards, Eliezer