LVM Management of Linux

Source: Internet
Author: User

Disk Management in the network is a very important management, the disk storage of important information, it is related to the normal operation of the entire network, we also know that the various data for the enterprise is changing all the time, for the fast-growing enterprises, its data information is also growing rapidly, How do we plan to store the information capacity of the enterprise in advance, it seems that we can not predict the future. In this case, the LVM in Linux is a good solution to this problem, the topic of this blog is about Linux Disk Management LVM introduction.

One: What is LVM

LVM: Logical Volume Management (Logical Volume Manager, abbreviated toLVM)It is a Linux environment for disk partitioningA mechanism for management, LVM is a logical layer built on the hard disk and partition, and we can manage the logic layer through LVM. 650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3D/F1/wKiom1PF6faCqwjsAADrU4DhhyI941.jpg "title=" 1.png " alt= "Wkiom1pf6facqwjsaadru4dhhyi941.jpg"/>

Second: Why should have LVM management

We have talked about the enterprise data information is changing all the day, the future of the enterprise's disk there is no extra space can be used to store data, there is no way to achieve the enterprise disk space in the case of downtime to expand it, with the advent of LVM these problems we can solve.



Three: The LVM layers are introduced.

PV(physical VOLUME,PV): Physical volume, physical disk partition but its file format is not ext4 these, Instead, the LVM format with LVM management is in 8e format in the disk partition file format selection (for disk partitioning we are not doing too much introduction here).

VG(Volume GROUP,VG): Volume group, the volume group is created on the basis of the PV physical volume, the volume group is composed of one or more physical volumes, the volume group can be expanded and scaled down on the basis of the physical volume PV.

PE(physical extent,pe) each physical volume can only be extended to PE after the expansion of the VG, it is equivalent to a number of blocks of the same size (the default is 4M, you can specify a size of 2 of the n-th square m), the VG is composed of these PE blocks , formally because these PE block VG can achieve free expansion and reduction.

The LV (logical VOLUME,LV) logical volume, created on the basis of VG, can be formatted and the file system created can be mounted. For the user is equivalent to a disk but actually in the VG logic, can be extended and reduced but on the basis of the VG, the expansion of the boundary is not likely to exceed the VG.


Four: Management of LVM

We can see that the creation of LV was created on the basis of VG, and the VG was created on the basis of PV. So if we want to create a LV, we have to start with PV, and the following are the management commands for each volume.


1) Management commands for PV.

pvcreate, PVs, Pvdisplay, Pvremove, Pvmove, Pvscan

Pvcreate: Create PV, the format of the disk partition to be 8e LVM format.

pvcreate/path/device{#,#}


PVS: Can be viewed with PVS after the creation is complete.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/3E/07/wKiom1PF-CXS6uVQAAFQWRmsD8I241.jpg "title=" Pvcreate.png "alt=" Wkiom1pf-cxs6uvqaafqwrmsd8i241.jpg "/>

Display: View details for each disk (specify that disk number later)

display/path/device#

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/3E/07/wKioL1PF-iSSgnpGAAGihHHzTiI629.jpg "title=" Display.png "alt=" Wkiol1pf-issgnpgaagihhhztii629.jpg "/>

Pvremove: Removing a disk

pvremove/path/device#

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3E/07/wKiom1PF-kHAVwHyAAEveL9k7JI826.jpg "title=" Pvremove.png "alt=" Wkiom1pf-khavwhyaaevel9k7ji826.jpg "/>

Pvscan: View information for each disk.


2) Management order of VG

Vgcreate, VGs, Vgdisplay, Vgremove, Vgextend, Vgreduce, Vgscan


Vgcreate: Create VG

Vgcreate VG's name/path/device#

VGS: View the VG information

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3E/08/wKiom1PF_zDhMcvdAAER9K7JkC8804.jpg "title=" Vgcreate.png "alt=" Wkiom1pf_zdhmcvdaaer9k7jkc8804.jpg "/>

Vgextend: Extended VG

Vgextend VG's name/path/device#

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3E/09/wKiom1PGAKSyPmG0AAEqc0STrrE301.jpg "title=" Vgextend.png "alt=" Wkiom1pgaksypmg0aaeqc0strre301.jpg "/>


Vgreduce: Remove VG

Vgreduce VG's name/path/device#


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/3E/0D/wKiom1PGGUvjY1O5AAEsW38ksq8158.jpg "title=" Vgremove.png "alt=" Wkiom1pgguvjy1o5aaesw38ksq8158.jpg "/>


Vgremove: Remove VG (use Vgreduce to transfer data before removing VG)

Vgremove VG Name


Vgdisplay: Lists all the VG information.


3) Management order of the LV

Lvcreate, LVs, Lvdisplay, Lvremove, Lvextend, Lvreduce, Lvscan

Lvcreate: Creating the LV

lvcreate-l LV Size-n-LV's name of the VG

LVS: View information about the LV

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/3E/0C/wKioL1PGEMOANLEPAAFdDzxJ7pk302.jpg "title=" Lvcreate.png "alt=" Wkiol1pgemoanlepaafddzxj7pk302.jpg "/>

Lvextend: Size of the extended LV

Before you extend the LV, check to see if the size you want to extend exceeds the size of the space that the VG has left. Extended LV to extend the physical boundary and then extend the logical boundary first.

Extended physical boundary: lvextend-l 5G/PATH/VG name/lv name

Force file Detection: e2fsck-f/PATH/VG name/lv name

Extended logical Boundary: RESIZE2FS/PATH/VG name/lv name

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3E/0E/wKioL1PGHCXyeTSBAACFaJNXk_o250.jpg "title=" Boundary problem. png "alt=" wkiol1pghcxyetsbaacfajnxk_o250.jpg "/>


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/3E/0D/wKioL1PGFimAbqGjAAVulh_HzjM475.jpg "title=" Lvextend.png "alt=" Wkiol1pgfimabqgjaavulh_hzjm475.jpg "/>


Lvreduce: reducing LV

Reduced LV (reduced risk, reduced to offline)

1 First determine the size of the reduction and ensure that the corresponding target logical volume has the data that can accommodate the original

2 unmount the file system first

3 Mandatory detection e2fsck-f/PATH/VG name/LV name

4 reduction of logical boundaries RESIZE2FS/PATH/VG name/LV name size

5 Reduction of physical boundaries lvreduce-l size/PATH/VG name/LV name

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/3E/0D/wKiom1PGF2_jFdfSAAVBHOIryJc499.jpg "title=" Lvreduce.png "alt=" Wkiom1pgf2_jfdfsaavbhoiryjc499.jpg "/>


Lvremove: Remove LV

LVREMOVE/PATH/VG name/lv Name

Five: Creation of the LV

To create the LV must first create the PV, on the basis of PV to create a VG, on the basis of the VG in the creation of LV. The Friends of the group tried to create a LV bar by following the logic and the commands given above. Of course, the deletion should start with the LV first step forward.

Because of my limited ability, I hope we can criticize.

This article from "Slayer" blog, declined reprint!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.