Removing Physical Volumes

If a device is no longer required for use by LVM, you can remove the LVM label with the pvremove


If the physical volume you want to remove is currently part of a volume group, you must remove it from

the volume group with the vgreduce command.




Removing Physical Volumes from a Volume Group

Before removing a physical volume from a volume group, you can make sure that the physical volume

is not used by any logical volumes by using the pvdisplay command.






We have two LVM partition




Create physical volume and volume group.




Check volume information.



Check volume group.



Create logical volume with name of “vg0”




Check logical volume.



Some other command


The following command creates a logical volume called mylvthat uses 60% of the

total space in volume group testvol.



The following command

creates a logical volume called yourlvthat uses all of the unallocated space in the volume group






Combining Volume Groups


Two combine two volume groups into a single volume group, use the vgmerge command. You can

merge an inactive “source” volume with an active or an inactive “destination” volume if the physical

extent sizes of the volume are equal and the physical and logical volume summaries of both volume

groups fit into the destination volume groups limits.


Here we have two volume group vg0 and vg1 ( both are equal size of 1GB )

Merge two volume group.




Check updated volume group.






Moving a Volume Group to Another System


You can move an entire LVM volume group to another system. It is recommended that you use the

vgexportand vgimport commands when you do this.

The vgexport command makes an inactive volume group inaccessible to the system, which allows

you to detach its physical volumes. The vgimport command makes a volume group accessible to a

machine again after the vgexport command has made it inactive.


To move a volume group form one system to another, perform the following steps:


1. Make sure that no users are accessing files on the active volumes in the volume group, then

unmount the logical volumes.


2. Use the -a n argument of the vgchange command to mark the volume group as inactive, which

prevents any further activity on the volume group.




3. Use the vgexport command to export the volume group. This prevents it from being accessed by

the system from which you are removing it.




When the system is next shut down, you can unplug the disks that constitute the volume group

and connect them to the new system.


4. When the disks are plugged into the new system, use the vgimport command to import the

volume group, making it accessible to the new system.




5. Activate the volume group with the -a yargument of the vgchangecommand.



6. Mount the file system to make it available for use.




Leave a Reply