Managing LVM with PVMOVE – Part 1

One of the challenging issues that i have encountered is the manipulation of LVM - Logical Volume Management on virtual servers. Whilst writing this article, i noticed that i have to split it into parts as it looks bulky in some sort. Once you have understand the logic of the LVM, things get pretty easy to deal with. I will elaborate some details of LVM, and will surely get into some brief real life experience that is important to grasp. Lets take an example of a disk where there are some applications running like MySQL, Apache, some monitoring tools like Atop and Htop which are writing on the disk and we have to shrink that very disk or replace it with another disk. Lets also assume that the server is running on an ESX host and the operation will be carried out through the VMware  VCenter. How do you shrink a disk having its application generating IOs? How do you replace a disk with a smaller one having its data on a LVM?

In brief, here is what i have understood from what is LVM - Logical Volume Management.

We have Physical Volume (PV), Volume Groups (VG) and Logical Volume  (LV). These terms are a must to understand before proceeding with Logical Volume Management operations.PV- These are hard disks or even Hard disk partitions. These PVs have logical unit numbers. Each PV is or can be composed of chunks called PEs (Physical Extents)

VG - The Volume Group is the highest level  of abstraction used with the LVM. Does this term looks complicated? I would say no. In the field of Software Engineering, there are two terms that are usually used that is modelling and meta-modelling. Just understand it like this if you are not familiar with software engineering.Modelling means one step or one level remove from reality whilst Meta-Modelling means modelling at a higher level of logic. So basically, it looks like some sort of higher modelling happened at the level of the VG. 

LV - The logical volume is a product of the VG. They are disks which are not restricted to the physical disk size and it can be resized  or even move easily without even having your application to be stopped or having your system unmounted. Of course, i need to do more research to get into more deeper explanation of the PV, PE, VG and LV. Lets now see an explanation through my horrible drawing skills.

Screenshot from 2015-09-29 21:04:46From the Diagram we conclude that :

  • PVs looks like hard disks divided into chunks called PEs
  • The VGs are just a high level of abstraction that should be look from the above.
  • VGs are created by combining PVs.

If you have access to a linux machine having LVM configured and some VG have already been created, you can start firing these commands to have an overview of the PV, VG and LV

  • pvs - Report information about physical volume
  • vgs - Information about volume groups
  • lvs - Information about logical volumes

Those physical disks can be picked up from the datastores, where RAID are configured. This act as another layer of security to be able to handle disk failures or lost of data at all cost.

Screenshot from 2015-09-29 21:37:28

On linux if you type vg or lv or pv press tab twice you will have an idea all the commands that exist and possibilities of manipulation. On part2 of this article i will take example of the pvmove command and actions that could be done to minimise impact before carrying out a pvmove operation.

Part2 of the article is on this link