CentOS under LVM logical volume creation and use

Linux disk management: LVM LVM logical basic concepts and works, a detailed explanation of the basic concepts of dynamic disk management Linux LVM logical volumes and LVM works, including LVM is the most important of the four basic points (PE, PV , VG and LV), this essay will explain in detail the creation of LVM logical volumes, use, and delete.

First, create LVM logical volumes

Illustrated the way we look at how to create our LVM, it is on an essay, we are already familiar with LVM works, first is to our physical hard drives formatted as PV, then added to create multiple PV good VG, the last created by our LV VG. So we first step is to our physical hard disk formatted into PV (physical volume)

① physical hard disk formatted into PV (physical volume) using pvcreate command

Here I have three quick advance virtualization physical drives, each drive’s size is 8G, by fdisk -l command to view
Copy the code

复制代码

复制代码

Here we are in accordance with the above figure, we first / dev / sdb, / dev / sdc two hard drives formatted as PV

After you create the PV, we can use pvdisplay (show details), pvs command to view information about the current pv

复制代码

复制代码

With these two commands, we can see a good PV information that we have created, two PV are 8G, there is no use, PFree is 8G.

② create a volume group (VG), and PV is added to the volume group by the vgcreate command

After you create the PV, this time we need to create a VG, then our PV are added to them this volume group, from the volume group when you create a volume group to give a name

Similarly, after the created VG, we can also use vgdisplay or vgs command to view information about VG

复制代码

复制代码

③ Based on the volume group (VG) create a logical volume (LV) by lvcreate command

Because creating good PV, VG are the bottom of things, we use the upper logical, so we have to create our logical volume is based VG job

VG created our logical name for the mylv, the size of 2G, we can use the same lvdisplay or lvs command to check the created logical volumes by lvcreate command based

复制代码

复制代码

This way we will have created a logical volume, and this time we take another look at our information via the PV and VG also vgs pvs command

复制代码

复制代码

We found that when we each have created a LV, VG and PV information is constantly changing, and we create the LV size is based on the current size of VG to the decision, no more than the remaining size of current VG!

We have talked in an essay on the inside, each created a logical volume, there will be a volume group named folder in the / dev directory, based on all of the logical volume group is created that is stored in this folder, we can look

We each create a new logical volume, the VG catalog will be more such a device.

Second, the format and the use of our logical volumes

We have created our PV, VG and LV, this time if we want to use the logical volume, it must be formatted as we need to use the file system, and mount up, and then you can go as using the same partition using logical volumes of
 

复制代码

复制代码

 

After our logical format, you can use the mount command to be mounted, we will mount it to / mnt directory

复制代码

复制代码

We see that our group has mounted a good volume, and can use as partitions to be the same document operate.

Third, delete the logical volume

After we created a logical volume by creating a file system, mount the logical volume to use it, if we do not want to use or it can be deleted.

[Note:] to create a physical volume, create a volume group and create logical volumes we have a strict order, also, to remove the logical volume, delete the volume group and remove the physical volume is also a strict sequence requirements

① First, the logical volume is being used by umount command uninstall

② to delete the logical command by lvremove

③ Delete volume group commands by vgremove

④ Finally, we come to remove the physical volumes by pvremove command

复制代码

复制代码

At this point we just created logical mylv, xiaoluo volume group and physical volume / dev / sdb has been removed from our current operating system out by lvs, vgs, pvs command to check

复制代码

复制代码

essays explain in detail the creation of LVM logical volumes, use and remove, in the next essay we will continue to explain the knowledge LVM logical volumes, including how the logical volume dynamic stretching and compressing them! ! !