Removing Physical Volumes

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

Command.

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.

 

clip_image002[4]

 

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.

 

clip_image004[4]

 

 

 

We have two LVM partition

 

clip_image006[4]

 

Create physical volume and volume group.

 

clip_image008[4]

 

Check volume information.

clip_image010[4]

 

Check volume group.

 

clip_image012[4]

Create logical volume with name of “vg0”

 

clip_image014[4]

 

Check logical volume.

clip_image016[4]

 

Some other command

 

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

total space in volume group testvol.

clip_image018[4]

 

The following command

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

testvol.

clip_image020[4]

 

 

*******************************************************

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.

 

clip_image022[4]

 

Check updated volume group.

 

clip_image024[4]

 

 

 

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.

 

clip_image026[4]

 

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.

 

clip_image028[4]

 

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.

 

clip_image030[4]

 

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

clip_image032[4]

 

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

 

clip_image034[4]

 

Leave a Reply