[MUSIC]
Welcome, in this video,
I will be covering the commands use to extend a volume group,
followed by the commands to reduce a volume group.
A volume group is a storage pool made up of one or
more physical volumes.
One of the advantages of LVM is that you can increase the size of
the volume group pool by adding new physical volumes to
the volume group.
If you do not have a physical volume free for
allocation to the volume group, then you may need
to perform a pvcreate on a physical device first.
Of course, if that device is a disk partition, then you may
also need to use fdisk before creating the physical volume.
Both of these steps are identical to the steps used in
creating a logical volume.
So, I won't detail them here,
although you can watch me as I perform them.
I have created a new 512 megabyte partition on /dev/vda.
And set its type to Linux LVM.
I have also executed the pvcreate command using
/dev/vda3.
The next step is to add the physical volume to the volume
group.
But before we do,
let's check the current size of the volume group with vgdisplay.
Note, the VG size value.
And you may also want to note the free PE/size value, as well.
vgextend vg-alpha /dev/vda3, will extend the vg-l for
volume group by the size of the physical volume /dev/vda3.
We can verify this by looking at vgdisplay again,
the total vg size and more importantly the free PE/size
have increased by the size of the new physical volume.
We can now extend existing logical volumes or
add new logical volumes in the free physical extend space.
One of the reasons for
extending a volume group with a new physical volume, may be to
replace a physical volume that is showing signs of failing.
Or, perhaps
you want to replace slower hardware with faster hardware.
A shiny new SSD, for instance.
In this demonstration, let's assume that /dev/vda2 is
showing signs of pending failure, and
that /dev/vda3 is our replacement device.
To remove the physical volume /dev/vda2 from the volume group,
I first need to move all the physical extent from that
physical volume.
To free physical extents, elsewhere in the volume group.
pvmove /dev/vda2 will do this for us.
The previous vgextend command ensured that we would have
sufficient free physical extents to perform this operation.
You can perform this operation, while users are still using
logical volumes within the volume group.
It is recommended that you back up data stored on all logical
volumes in the volume group before using pv move.
An unexpected interruption during the move, such as a power
failure, may leave the volume group in an inconsistent state.
Which in turn, may cause loss of data in the logical volumes
in the volume group.
vgreduce vg-alpha /dev/vda2 would
then remove the physical volume from the volume group.
If the physical volume was removed,
so that it could be reallocated to another volume group, then
you can now use vgextend with this physical volume
on the new volume group.
Alternatively, pvremove can be used to wipe the lvm metadata
from the device, reverting the physical volume to a normal
disk or partition again.
To recap, extending a volume group may require you to prepare
a physical device and use pv create, followed by
vg extend to add the physical volume to the volume group.
You use vgdisplay to verify the new size.
To reduce a volume group, use pvmove to redistribute
the physical extents from the existing volume.
And then vgreduce to remove the physical volume from
the volume group.
The physical volume is now free to be reallocated to another
volume group or decommissioned as a physical volume.
That concludes this video.
Thanks for watching.