Manage and Create LVM volumes in CentOS

Source: Internet
Author: User
I. LVM (LogicalVolumeManager) 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. DM logical device introduction 1. physical volume (PysicalVolume): physical disk, similar to/dev/sda2,/dev/sdb1 and so on. it consists of physical disk blocks of PE (PhysicalExtends; multiple PVS can be combined to form

I. LVM (Logical Volume Manager) 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.

Introduction to DM logical devices

1. Physical Volume (Pysical Volume): This is a Physical disk. it is similar to/dev/sda2,/dev/sdb1, and is composed of Physical disk blocks of PE (Physical Extends; multiple PVS can be combined to form a VG (Volume Group)

2. volume Group: a Group composed of multiple physical volumes, which cannot be used directly. to use the combined space, you must create a logical volume. The VG size depends on the physical volume, multiple logical volumes can be divided in VG (dynamic scaling is allowed)

3. PE (Physical Extend): specifies the block size when creating VG. the default value is 4 MB. A vg can contain a maximum of 65534 PES.

4. Logical Volume: it can be all the available space of the Volume group. It has two kinds of boundaries: physical boundaries and Logical boundaries; it can also be said that each logical volume is a file system or an independent partition. Creating a snapshot for a volume is actually creating a snapshot for a logical volume, that is, the snapshot volume is in the same volume Group as its logical volume.

5. snapshots can be understood as another way to access the same file. data stays at a certain time in the past, mainly for data backup.

II. Command Introduction

1. physical volume command

1.1 pvcreate (create pv) pvs (view pv information) pvdisplay (view pv details) pvmove (transfer PV data to other pvs) pvremove (delete PV) pvscan (scan pv)

Pvcreate: Create a pv physical volume such as pvcreate/dev/sdb1.

Pvs: view the pv physical volume, for example, pvs/dev/sdb1.

Pvdisplay: View pv details, such as pvdisplay/dev/sdb1.

Pvmove: move the data on the pv physical volume to another pv, for example, pvmove/path/to/pv.

2. Volume Group Command

2.1 vgcreate (create vg) vgremove (delete vg) vgextend (scale vg) vgreduce (scale vg) vgs (view vg information) vgdisplay (view vg details) vgscan (scan vg)

-S: specifies the PE

Vgcreate myvg/dev/sdb {n, n} create a VG volume Group

Vgdisplay myvg view only the myvg volume Group

Vgremove myvg: delete the myvg volume Group (delete a vg)

Vgreduce VG_NAME/path/to/pv: reduce the vg, which means that the pv can be reduced (the pv data must be removed first)

Pvmove/dev/sdb1 remove the data above sdb1

Vgreduce myvg/dev/sdb1 removed from myvg/dev/sdb1

Pvremove/dev/sdb1 delete/dev/sdb1

Extension vg: vgextend myvg/dev/sdb2 extension myvg volume Group

3. logical volume command

3.1 lvcreate (create lv) lvremove (delete lv) lvextend (extend lv) lvreduce (reduce lv) lvs (view lv information) lvdisplay (view lv details) lvscan (scan lv)

Lvcreate-L + G (specified space size)-n LV_NAM (logical volume name) VG_NAME will automatically expand VG_NAME

Lvdisplay: displays all lv logical volumes, such as dev/myvg/testlv.

(Note: the commands here are not listed one by one. The usage methods are similar .)

3.2 Logical volume expansion and reduction requirements:

3.2.1 expansion requirements

(1) check the file system before expansion

(2) the logical volume boundary is created close to the physical volume edge world.

(3) expand the physical volume boundary first, and expand the logical volume boundary

3.2.2 Requirements for logical volume reduction

(1) cannot be reduced online. you need to uninstall it first.

(2) ensure that the reduced space size can still store the original data

(3) files should be forcibly checked before reduction to ensure normal use of the file system

3.2.3 snapshot volume

(1) the lifecycle is the entire data duration. during this period, the data growth cannot exceed the snapshot volume size.

(2) the snapshot volume should be read-only and cannot be modified to ensure the data status at that moment.

(3) in the same volume group as the original volume

III. example:

3.1 create a 10 GB VG

3.1.1 create two primary partitions on the/dev/sdb hard disk: 5 GB, for example:

# Fdisk/dev/sdb

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.