Centos disk management-LVM

Source: Internet
Author: User

LVM is short for logical disk volume Management (LogicalVolumeManager). It is a mechanism for managing disk partitions in Linux. LVM is a logical layer built on hard disks and partitions, to improve the flexibility of disk partition management. The LVM system administrator can easily manage disk partitions. For example, you can connect several disk partitions to an entire volume group (volumegroup) to form a storage pool. The administrator can create a logical volume group (logicalvolumes) and create a file system on the logical volume group. Through LVM, administrators can easily adjust the size of the storage volume group, name, manage, and allocate disk storage by group, and provide snapshot functions.

Basic concepts:

In theory, Logical volumes can be divided into three layers. The lowest layer is PV (Physical Volume), the middle is VG (Volume Group), and the top layer is LV (Logical Volume)

PV: it can be a separate disk, a partition on a disk, or RAID.

VG: similar to extended partitions, which cannot be used directly and must be partitioned into LV

LV: it is equivalent to the partition of the disk. It needs to be formatted and mounted before use. The space is N times the size of PE.

PE: physical disk area, which is defined when VG is generated. It is the most basic storage unit allocated to the logical volume. Generally, it is 2 ^ n mb. The default value is 4 MB.

LE: Logical Disk area. After assigning the number of PES in VG to the logical volume, it becomes LE.

Generally, the size of a logical volume is called a physical boundary;

The file system size is called a logical boundary or a file system boundary.

When expanding a logical volume, expand the physical boundary before expanding the file system boundary;

When reducing the logical volume, it is risky to first reduce the file system boundary and then the physical boundary!

The snapshot function of the logical volume facilitates data backup. the snapshot volume is the access point of the original file. When a snapshot is created, the data is locked, if the data on the original logical volume is not changed when the data is accessed through the snapshot volume, there is no data in the snapshot volume, and only the ing of the files on the original logical volume is displayed, after a snapshot volume is generated, only the original data of all the changed data on the original logical volume will be copied to the snapshot volume, so the snapshot volume size is generally much smaller than the original logical volume. The maximum used space of the original logical volume will not exceed.

Logical volume management command:

1. Create a PV

Pvcreate device is used to create PV

Pvdisplay device is used to display PV information, and pvs briefly displays PV information.

2. Create VG

Vgcreate VG_name/path/to/PV

-L specify the maximum number of LV IDs that can be created

-P: Maximum PVS

-S: Specifies the PE size.

VG command:

Vgdisplay, vgs

3. Create an LV

Lvcreate LV_name VG_name

-C: Specify chunk size

-L specify the number of LE

-L specifies the LV size, in MB

-N specifies the LV name.

-P specifies the read and write permissions.

-S: Specify snapshot creation.

When viewing a single lv, you must specify the path:

Lvdisplay/dev/VG_name/LV_name

Lvdisplay/dev/mapper/VG_name-LV_name

4. Format and mount the LV:

Formatting and mounting LV is the same as general partitions

Mke2fs-t ext4/dev/VG_name/LV_name

Mount/dev/VG_name/LV_name Mount_point

5. Extend the logical volume group

First, prepare PV

Then vgextend VG_name/path/to/PV

6. Reduce logical volume groups

Determine the PV to be removed;

Move the data on this PV to another PV; pvmove/path/to/PV

Remove the PV from the volume group; vgreduce VG_name/path/to/PV

Take removing hda6 as an example:

7. Expand LV

Determine the scale size;

Make sure that the current VG has enough free space;

First, expand the physical boundaries, and then expand the file system boundaries.

An exception occurred during implementation. on-line resize is not supported. Follow the prompts to handle it;

If you need to perform file system detection after the LV extension is complete, you need to uninstall it first;

8. LV reduction

It is determined that the scale-down is large, provided that it can accommodate at least all the original data.

1. Check the file system e2fsck-f/path/to/LV

2. Uninstall LV

3. Reduce logical boundaries (file system boundaries)

4. Reduce physical boundaries

5. Check the file system

9. snapshot volume

Lvcreate-l size-s-n Snap_name/path/to/lv

10. Remove logical volumes, Volume groups, and PV

Uninstall and remove

Lvremove/path/to/lv

Vgremove VG_name

Pvremove/path/to/pv

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.