How to deactivate a LVM2 physical volume to remove the drive?

user2650268 picture user2650268 · Aug 4, 2013 · Viewed 73.5k times · Source

How can I shut down/"unmount" a Linux lvm2 physical volume?

I plugged an external had drive to my computer. On the drive is a LVM2 PV with one volume group which has some logical volumes. I now want to remove this drive again properly.

I unmounted the filesystems, deactivated all logical volumes and the volume group.

How can I deactivate the physical volume? Or make the PV and the VG unknown to Linux again? Like just the opposite of lvmdiskscan and vgchange -a y ?

I want to leave the PV/VG and LVs on the disk intact.

Answer

StianE picture StianE · Aug 4, 2013
lvchange -an <lvpath>
vgchange -an <vgname>

If you also want to remove the device maps you can use

dmsetup ls
dmsetup remove <name>