Basic concepts and Management of LVM

Source: Internet
Author: User

Basic concepts and Management of LVM

I. Problems with traditional disk management

When the partition size is insufficient, it cannot be expanded. You can only add a disk or create a new partition to expand the space. However, the newly added hard disk exists as an independent file system, the original file system is not extended, and upper-layer applications can only access one file system. You can only deprecate an existing disk, replace it with a new disk, and then import the original data.

Ii. Basic concepts of LVM logical volumes

The Logical volume Management of LVM (Logical volume Manager) abstracts the underlying physical hard disks and presents them to the upper-layer system as Logical volumes. The Logical volume size can be dynamically adjusted, and existing data will not be lost. The new hard disk does not change the logical volume on the upper layer.

As a dynamic disk management mechanism, logical volume technology greatly improves the flexibility of disk management.


PE (physical extend) is a basic block of 4 MB by default.

PV (physical volume) hard disk or partition

VG (volume group) is composed of one or more PVS.

The space cut by LV (logical volume) from VG is used to create a file system.

Iii. LVM creation process
1. The physical disk is formatted as PV, and the space is divided into PES.
2. Add the same VG to PV without passing through. All pes with different PVS enter the PE pool of VG.
3. LV is created based on PE and the size is an integer multiple of PE. The PE that makes up LV may come from different physical disks.
4. LV can be directly formatted and mounted and used now.
5. LV expansion and reduction is actually to increase or decrease the number of PES that make up the LV. The process does not lose raw data.

4. Create LVM

Initialize a physical disk device as a physical volume


Create a volume group and add PV to the volume group

Vgcreate vg0/dev/sdb/dev/sdc

Create logical volumes based on volume groups

Lvcreate-n lv0-L 5G vg0

Create a file system for the created logical volume

Mkfs. ext4/dev/vg0/lv0

Mount and use formatted logical volumes


The mounting information is written to/etc/fstab and restarted.

Echo "/dev/vg0/lv0/mnt ext4 defaults 0 0">/etc/fstab

5. View LVM

View physical volume information: pvs and pvdisplay (details)

View volume group information: vgs and vgdisplay (details)

View logical volume information: lvs and lvdisplay (details)

6. Delete LVM

Delete LV: lvremove/dev/vg0/lv0

Delete VG: vgremove vg0

Delete PV: pvremove/dev/sdb

7. Stretch a logical volume

The logical volume stretching operation can be performed online without detaching the logical volume.

Ensure sufficient free space in VG

Vgs, vgdisplay

Expand logical volume

Lvextend-L + 5G/dev/vg0/lv0

View the expanded LV size

Lvs and lvdisplay

Update File System


View the updated File System


8. Stretch a volume group

Format the hard disk to be added to VG as PV


Add a new PV to a specified volume group

Vgextend vg0/dev/sdd

View the expanded VG size

Vgs, vgdisplay

9. Narrow down a logical volume

The logical volume downgrading operation must be performed offline. You must detach the logical volume.

Detach a mounted logical volume


Shrink the file system (the original lv0 is 10 Gb)


Resize2fs/dev/vg0/lv0 3G

LV reduction


View the resized LV

Lvs and lvdisplay



10. shrink the volume group

Removes a PV from a specified group.

Vgreduce vg0/dev/sdd

View the size of the reduced volume group

Vgs, vgdisplay

Remove PV


LVM2 details

Use LVM on Ubuntu to easily adjust partitions and create snapshots

Use LVM to create elastic disk storage-Part 1

Expanding/downgrading LVM in Linux (Part 2)

Recording and restoring logical volume snapshots in LVM (part 3)

Set a streamlined resource allocation volume in LVM (part 4)

Use fragmented I/O to manage multiple LVM disks (Part 5)

This article permanently updates the link address:

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: 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.