Linux LVM detailed

Source: Internet
Author: User

"LVM"

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

    • Why use LVM?
LVM is typically used for systems equipped with a large number of disks, but it is also suitable for only one, A small system of two hard disks.

What are the benefits of using LVM for small systems?
The traditional file system is partition-based and a file system corresponds to a partition. This method is more intuitive, but not easy to change:
1. Different partitions are relatively independent, there is no correlation, the space of each partition is easy to use the imbalance, the room can not be fully utilized;
2. When a file system/partition is full, it cannot be expanded, only with repartitioning/file system, very troublesome , or move the data in the partition to another larger partition, or use a symbolic connection to make space for other partitions.
3. If you want to combine multiple partitions on a hard disk, you can only use the partitioning method, which requires data backup and recovery.
When using LVM, the situation is different:
1. 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 changes size as needed (within the volume group capacity) to meet the requirements;
3. The file system is built on LVM and can be used across partitions for ease of use;


What are the benefits of using LVM for large systems?  
in large systems with many hard drives, the use of LVM is primarily easy to manage, Increases the scalability of the system. In a large-scale system with many different capacity drives, the spatial allocation of different users is a tricky task, which seeks to balance the user's needs with the actual available space. The user/user group space is built on the LVM and can be increased at any time, or adjusted for each logical volume according to usage. When the system is running out of space and adding a new hard disk, it is not necessary to migrate the user's data from the original to the new hard disk, but only to add the new partition to the volume group and expand the logical volume. Similarly, using LVM can be a non-stop service scenario. Transfer user data from the old hard drive to the new hard disk space.  

consists of n disks that make up a large space VG1, and then partition the partitions that need to be used from the VG1.

Partitioning a portion of disk space from the remaining space to a partition

Thus, when there is not enough space for a partition, this can increase the disk space used by this partition.


" noun explanation "
    •       PV (physical Volume): physical volume, at the bottom of the LVM, can be a physical hard disk or partition.
    •       PP (physical Extend): physical area, PV can be used to allocate the smallest storage unit, can be created when the PV, such as 1M, 2M, 4M, 8M, 32M, 64M ... The PE size of all PV that comprise the same VG should be the same.
    •       VG (Volume Group): Volume Group, Built on PV, can contain one to multiple PV.
    •       LV (Logical Volume): Logical Volume, Built on the VG, equivalent to the concept of the original partition. However, the size can be changed dynamically.

" Create LVM"
1. View newly added hard drives in the system


2, partition the disk (create PV) on the/DEV/SDB partition of two partitions







3. Use the fdisk–l command to view the partition table

4. After the partition is built, use the pvcreate command to create the PV on the newly created partition.

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

6, with lvcreate–l 500m–n lv01 vgdate command from the VG vgdate to create a size of 500M, named Lv01 LV

The first LV we created is located in the directory/DEV/VGDATE/LV01
7. Format the LV01 with the mkfs/dev/vgdate/lv01 command


8, the file system under Linux needs to be mounted before it can be used, we first use the Mkdir/date command to create an empty directory, and then use the Mount/deta/vgdate/lv01/date command to mount our LV01 partition to the/date directory, Our newly created LV is now ready for use.
















LVM Walkthrough of Linux

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.