LVM Management in Linux

Source: Internet
Author: User

What is Lvm?

LVM (Logical Volume Manager) Logical volume management, is a partition of one or more hard disks in a logical collection, equivalent to a large hard disk to use, when the hard disk space is not enough to use, you can continue to add the partition of other hard disks, This can be a matter of dynamic management of disk space, relative to the normal disk partition has a lot of flexibility, the use of ordinary disk partitioning, when a disk partition space is not enough to use, it can be a lot of trouble. Using LVM to some extent can solve the problems caused by ordinary disk partitioning.

650) this.width=650; "src=" Https:// "title=" Picture 1.png "alt=" Wkiom1mk3spbd4x9aaavibhbung817.png "/>

LVM structure diagram

Why use Lvm?

LVM is typically used for systems with large volumes of disks, but it is also suitable for small systems with only one or two hard disks. The most important feature of LVM is the ability to dynamically manage disks. Because the size of the logical volume can be dynamically adjusted, and no existing data is lost. If we add a new hard disk, it will not change the existing upper-level logical volumes. As a dynamic disk management mechanism, logical volume technology greatly improves the flexibility of disk Management.

When using LVM, the situation is different:
1. The multiple partitions of the hard disk are managed by the LVM Unified for the volume group, can easily join or remove the partition to enlarge or reduce the volume group's usable capacity, make full use of the hard disk space;
2. The file system is built on a logical volume, and the logical volume can vary in size (within the volume group capacity) as needed to meet the requirements;
3. File system based on LVM, can be cross-partitioned, easy to use;

Basic Logical Volume Management concepts:

PV (physical Volume)-Physical volume

The physical volume is at the very bottom of the logical volume management, which can be a partition on the actual physical hard disk, or it can be an entire physical hard disk or a RAID device.

VG (Volumne Group)-volume group

A volume group is built on a physical volume (PV) and at least one physical volume is included in a volume group, and physical volumes are dynamically added to the volume group after the volume group is established. A logical volume management system can have only one volume group, or multiple volume groups.

LV (Logical Volume)-Logical Volume

A logical volume is built on top of a volume group (VG), and unallocated space in a volume group can be used to create new logical volumes that can be dynamically scaled and scaled down after the logical volume is established. Multiple logical volumes in a system can belong to the same volume group, or they can belong to different volume groups.

Create LVM(The following is a simple example of how LVM is created)

Example: Create a VG named TESTVG that has at least two PV and a size of 20G, requires a PE size of 16MB, and then creates a logical volume with a size of 5G in the volume group TESTLV; mount to the/users directory

1. Check that there are not enough hard drives in the system.

650) this.width=650; "src=" Https:// "title=" Picture 2.png "alt=" Wkiol1mk3unrd9cvaacpsbsfhkg072.png "/>

2. Create the PV on the newly created partition with the Pvcreate command.

650) this.width=650; "src=" Https:// "title=" Picture 3.png "alt=" Wkiol1mk3v6grc7vaaadnnihvli386.png "/>

3. Use the vgcreate command to create a VG named TESTVG, and add all new PV to the TESTVG.

650) this.width=650; "src=" Https:// "title=" Picture 4.png "alt=" Wkiom1mk3yxswtteaaa9p-1ul0u730.png "/>

4. Use the Lvcreate-l 5g-n/DEV/TESTVG/TESTLV to create a lv named TESTLV.

650) this.width=650; "src=" Https:// "title=" Picture 5.png "alt=" Wkiom1mk3zzwke0saaa7qilgnyg740.png "/>

5. format the type of TESTLV with MKFS.EXT4/DEV/TESTVG/TESTLV.

650) this.width=650; "src=" Https:// "title=" Picture 6.png "alt=" Wkiol1mk30gddnm9aabq_lyglky198.png "/>

6, the file system under Linux need to be mounted before use, we first use the Mkdir/users command to create

Create an empty directory, and then use the mount/dev/testvg/testlv/users/command to send our

The TESTLV partition is mounted to the/users directory, so our newly created LV is ready to use.

650) this.width=650; "src=" Https:// "title=" Picture 7.png "alt=" Wkiol1mk316wfyieaabbootlpby552.png "/>

Note: Attentive little friends may find that the equipment we have mounted is /DEV/TESTVG/TESTLV , and here's how it shows up /DEV/MAPPER/TESTVG-TESTLV ? You can think about what the hell is the matter with them? 650) this.width=650; "src=" Http:// "alt=" j_0005.gif "/>



I will not suspense, in fact they both point to the same link 650) this.width=650; "src=" Http:// "alt=" J_0046.gif "/>

650) this.width=650; "src=" Https:// "title=" Picture 8.png "alt=" Wkiol1mk33psqnv0aaayiahpxbe978.png "/>

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