Linux Learning Note 11 (LVM Basics)

Source: Internet
Author: User

In the case of hard disk shortage, the usual practice is to use symbolic links or tools to resize partitions (parted), but these practices are only a temporary change of the difficult situation, and after each change in the size of the partition to restart the system, as a system administrator, restart is not allowed, So LVM is a good choice to solve this situation.

Content:

    1. Basic concepts of LVM (logical Volume management program):


PV (physical volume): Physical volumes are at the bottom of the logical volume management system and can be partitions on the entire physical hard disk or on the actual physical hard disk.

VG (Volume Group): A volume group is built on a physical volume, and a volume group must include at least one physical volume, which can be dynamically added to the volume group after the volume group is established, and can have multiple volume groups in a logical volume management system engineering. (same as PE in the same VG)

LV (logical volume): Logical volumes based on volume groups, unallocated space in a volume group can be used to establish new logical volumes that can be dynamically scaled and scaled down after the logical volume is established.

PE (physical extent): The physical region is the smallest storage unit available for allocation in a physical volume, the physical region size is specified when the volume group is established, and once determined that it cannot be changed, the physical region size of all physical volumes of the same volume group must be the same, the new PV is added to the VG, The size of the PE is automatically changed to the PE size defined in the VG.

LE (logical extent): The logical region is the smallest storage unit that can be allocated in a logical volume, and the size of the logical region depends on the size of the physical region in the volume group where the logical volume resides.

Volume Group Description Area: The volume group description area exists in each physical volume, and is used to describe the physical volume itself, the volume group to which the physical volume belongs, the logical volume in the volume group, the allocation of physical regions in the logical volume, and all information that is established when a physical volume is created using Pvcreate.

Fundamentals of 2.LVM

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4C/2F/wKiom1Q4lLbC7QLPAAEv70xyS04672.jpg "title=" volume group description. PNG "alt=" Wkiom1q4llbc7qlpaaev70xys04672.jpg "/>

Description: LVM organizes a single disk or partition into a VG,VG that can be seen as a large disk or partition for LV planning zoning.

Summary of several commands for 3.LVM:

PV:

Pvcreate
Create PV
Pvremove Remove PV (delete)
Pvscan Scan for more PV information (brief information)
Pvdisplay|pvs View PV Specific Information-Brief information
Pvmove The disk (partition) information to be removed is transferred to the disk (partition)
Vg:
Vgcreate Create VG
-S #:pe size, default is 4MB
Usage:
Vgcreate VG_NAME/PATH/TO/PV
Vgremove Remove VG (delete)
Vgextend Extended VG
Vgreduce Reduce VG
VGs VG Information Query
Vgdisplay Show VG Details
Vgscan Scan VG for all information
Lv:
Lvcreate Create LV
Usage:
Lvcreate-n lv_name-l #G Vg_name
Lvremove Removed from
Lvextend Increase
Lvreduce Reduce
Lvs Display information
Lvdisplay Show more information

4. Specific implementation process:

    1. The process of creating LVM:

1) Start with an LVM-type partition (or disk)

2) Pvcreate for the creation of PV.

3) Vgcreate the creation of the VG.

4) Lvcreate the creation of the LV.

5) Create file system (MKE2FS)

6) Mount Lv.

2. Extending the logical Volume

1) If PV does not have enough capacity, first increase PV

2) If the VG does not have enough capacity, add the VG first

3) lvextend-l [+]#/path/to/lv

4) Resize2fs-p/path/to/lv (-P is the function of how much spare to expand how large)

5) Mount

3. Reduce the logical volume;

Note: 1, can not be reduced online, you have to uninstall first;

2, to ensure that the size of the reduced space can still store all the original data;

3, before the reduction should be forced to check the file, to ensure that the file system is in a sexual state;

Df-lh

Umount

E2fsck-f

    1. RESIZE2FS/PATH/TO/LV 3G (reduced to 3G)

    2. lvreduce-l [-]#/PATH/TO/LV

Re-mount

4. Snapshot Volume: (typically used to back up data, this data is at a certain point in time)

    1. Precautions:

      1, the life cycle of the entire data length, in this period of time, the amount of data growth can not exceed the size of the snapshot volume;

      2, the snapshot volume should be read-only;

      3, with the original volume in the same volume group;

    2. Implementation process: Lvcreate-s-L #-N slv_name-p r/path/to/lv (creates a snapshot for which logical volume)

      5. Delete LVM

      1) Uninstalling the device

      2) First uninstall LV

3) unmount the VG again

4) Uninstall again LV

Summary: LVM is also important in Disk Management. Not to be continued ...

This article from "Technology first" blog, declined reprint!

Linux Learning Note 11 (LVM Basics)

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.