How to create and use LVM in Linux

Source: Internet
Author: User

One: the concept of LVM: Logical Volume Manager ( Logical Volume Manage) is a virtual disk formed by a logical disk

management, which can also be called a disk partition.

II: The role of LVM: solve the situation where the partition space is insufficient or the partition space is more than sufficient. Because the size of the partition is just

partitioning has been fixed and cannot be changed. For example, we have a 8GB hard drive and a

20GB hard disk, want to divide into a 12GB and a 16GB of two logical disk, obviously in the object

not implemented on the management disk, this is logically divided into logical partitions

Three: some of the basic concepts involved in LVM:

PV: Physical Disk partition

VG: Merging multiple physical disks into the same volume group on which logical partitions can be partitioned

LV: A logical volume divided on a volume group

Four: How to implement LVM: first initialize the physical disk to the physical volume PV(which can be a few disk combinations or

The combination of the partitions) is then combined into a group (VG), which is then created on the basis of the volume group.

Volume (LV). To use a logical volume to format it (that is, to set up a file system)

V: The superiority of LVM over the direct use of physical storage:

1. Simple to single logical volume operation can change the size of storage capacity

2. Disk Fragmentation

3. You can use the snapshot

VI: The detailed implementation process of LVM:

1. Divide the SDB1,SDB2 two partitions on the newly added sdb hard drive and give the two partition types to Linux LVM 650) this.width=650; " Style= "Float:left;" src= "http://s3.51cto.com/wyfs02/M01/3F/A6/wKioL1PLxNqy-xI_AADih7N9_WI503.jpg" title= "1.png" alt= "Wkiol1plxnqy-xi_aadih7n9_wi503.jpg"/>


2. Use the command pvcreate/dev/sdb{1,2} to create a physical volume, and then use PVs to view


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3F/A7/wKioL1PLxinS4Sv7AAB2-vQxi4g077.jpg "title=" 2.png " alt= "Wkiol1plxins4sv7aab2-vqxi4g077.jpg"/>


3. use vgcreate sdvg/dev/sdb{1,2} to create a volume group SDVG with VGS View


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3F/A6/wKiom1PLxTTy_X4IAABXsPX7LRA053.jpg "title=" 3.png " alt= "Wkiom1plxtty_x4iaabxspx7lra053.jpg"/>


4. use lvcreate-n lv1-l 6G SDVG to Create the logical volume LV1 on the volume group SDVGand set the size to 6G and

LVS View


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3F/A6/wKiom1PLxbGSgpcNAADuf3e67Xw959.jpg "title=" 4.png " alt= "Wkiom1plxbgsgpcnaaduf3e67xw959.jpg"/>

5. To use lv1 to store data, you must format it (that is, create a file system) with the command MKE2FS

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3F/A6/wKiom1PLxgGSZjeyAALhSzLXlRc974.jpg "title=" 5.png " alt= "Wkiom1plxggszjeyaalhszlxlrc974.jpg"/>


Seven: Manage the created lv1 :

1. Expand The LV1, the physical boundary should be expanded first, the physical boundary expansion should determine the SDVG volume

There is enough space on the group to be available, and then extend the logical boundaries. Of course, if SDVG

When the space is not enough, you should expand the space of SDVG, when you need to add a magnetic

plate or stage into a PV volume and then use the Vgextend expansion SDVG.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3F/A6/wKiom1PLxuqRSd56AAHbGy1nvy0497.jpg "title=" 6.png " alt= "Wkiom1plxuqrsd56aahbgy1nvy0497.jpg"/>

Of Course, if the SDVG space is not enough, you should expand the SDVG space, at this time need to add

A disk or partition is made into a PV volume and then vgextend extended SDVG.

2. reduce lv1, You should first reduce the logical boundary, in the physical boundary reduction


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3F/A7/wKioL1PLyIihFXwQAAJirU5SPeg491.jpg "title=" 7.png " alt= "Wkiol1plyiihfxwqaajiru5speg491.jpg"/>

So the size of the LV1 is reduced.

Note: When reducing the logical volume, you should pay attention to the size of the reduction, or you will mistakenly delete the data, you should uninstall the device before shrinking


Eight: LVM snapshot: LMV Snapshots are the state of information that holds a moment in a logical volume for consistent backup or test data

update the effect without affecting true data. The size of the snapshot depends on the size of your content updates during a certain period of time.

How to create LVM:


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3F/A6/wKiom1PLyKHx0WB5AAFKT6OTi5U257.jpg "title=" 8.png " alt= "Wkiom1plykhx0wb5aafkt6oti5u257.jpg"/>

You can use it right now

Deletion of logical volumes:

Delete logical volumes should be deleted in the following order, snapshot volume, logical volume, Volume group, Object

roll.






























This article is from the Linux OPS blog, so be sure to keep this source http://germanygu.blog.51cto.com/3574209/1440609

How to create and use LVM in Linux

Related Article

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.