LVM functions in linux

Source: Internet
Author: User

Understand LVM Management in Linux:

LVM is short for LogicalVolume Manager (logical volume management). It is a mechanism for managing disk partitions in Linux. It can be deployed on multiple physical volumes (PVs) create a virtual disk volume group (VG) on the disk volume group, and then create a logical volume (LV) on the disk volume group to break through some restrictions imposed by traditional partitions, so we need to better understand LVM, first, you need to understand the limitations of traditional partitions, and then understand how LVM can break through these restrictions.


First, understand the restrictions on using traditional partitions:

Different partitions are relatively independent, and the utilization of each partition space is very unbalanced. For example, one partition is almost full, but another partition has a large capacity. When a partition storage is full, it cannot be flexibly expanded. If you want to resize the partition, you can only use this to be full, or the data in the already filled partition is copied to another storage device, and then the partition is re-planned to create a file system again, which is very troublesome. This process requires data backup and recovery. To sum up, you cannot perform incremental resizing on traditional partitions. The so-called incremental resizing is a 50 gb d partition, this time, we need to resize the D partition to 70 GB, and then scale it from 70 GB to 90 GB next time. In this process, we do not need to re-plan the partition table and format the partition.


LVMBreaking the concept of traditional partitioning:

As shown in 1: it breaks through the features of independent partitions on traditional hard disks. It splits several different physical volume PVS (in fact, sdb1 and sdc1 in the physical partition ratio ), plan to form a virtual volume group (VG), the so-called virtual volume group (VG) in fact, it is equivalent to organizing the free space on the physical volumes distributed in sdb1 and sdc1 into an overall virtual hard disk (also called virtual volume group VG), and then on this virtual hard disk (virtual volume group VG) re-planning the logical volume (LV) is equivalent to re-planning the partition on the virtual hard disk, and re-planning the partition (logical Volume LV), which features incremental resizing, for example, a logical volume is initially planned to be 10 Gb. When the capacity is insufficient, you only need to use the relevant commands to increase the capacity of the initial 10 Gb logical volume to 15 GB, during the entire capacity increase process, you no longer need to back up the data on the volume, format the data, and finally restore the data to the volume. VLM saves the tedious process of resizing the traditional partition, higher efficiency!


Demonstration: implementation and effect verification of LVM in Linux

Purpose: To demonstrate the implementation and effect verification of LVM in Linux.

Demo environment: Why is one Linux operating system with three scsi hard disks installed? This is not because of other requirements or reasons, but because the author's Linux system uses 1st hard disks to store boot and system files, and then uses the other two hard disks to complete this experiment, why use two hard disks? This is to let everyone see the effect of LVM collapsing multiple physical volumes. The entire experiment can be completed through a virtual machine.

Demo Background: the background of the demo is described as follows:

U first use fidis-l to check whether two new hard disks are installed.

Ü create two physical volumes by partitioning two hard disks.

U then specify the 8e format used by the LVM for the two physical volumes.

Ü create a virtual volume group, add two physical volumes to the virtual volume group, and activate the virtual volume group.

Ü create a new logical volume on the virtual volume group, format the volume using Ext3, mount the volume, and store data on the logical volume.

Ü then add the logical volume to experience the advantages of LVM.

Demo steps:

Step 1: Use fdisk-l in the terminal window to check whether the current Linux system uses the hard disk, and whether the two new hard disks used in the experiment are identified by the operating system, the disk number, and formatted, see figure 2;

Step 2: now go to the second Hard Disk/dev/sdb, and then create a physical partition for the hard disk, as shown in step 3, convert physical partitions to Linux LVM format, and finally save the partition table. This process is particularly important in the following steps. Otherwise, LVM creation will fail, note that the third Hard Disk/dev/sdc adopts the same operation steps, so we will not repeat the description here.

Step 3: Use fdisk-l again to view the status and format categories of the current system hard disk and partition, as shown in Issue 4. We can see two new hard disks, each hard disk is divided into only one partition. The partition numbers are sdb1 and adc1, and the format is LinuxLVM. This makes preparations for the final implementation of LVM.

Step 4: Configure LVM now, as shown in Figure 5. first create a physical volume consisting of two physical partitions, and then create a virtual volume group named vdisk1 on the physical volume, activate the virtual volume group and create a logical volume on the virtual volume group (equivalent to a new partition that can be used for incremental resizing ).

Step 5: After the logical volume is created, use the mkfs command to format the logical volume using ext3, as shown in figure 6, to ensure normal use of the new lvml logical volume, you must perform the Mount task like a regular physical partition. Otherwise, the volume cannot be used normally.


Note: It is not difficult to find that the LVM implementation process is as simple as the definition diagram of LVM. It is worth noting that after the logical volume of LVM is successfully created, you must also format and mount the volume. You must regard the logical volume as a normal physical volume. However, when resizing the volume, you will find its advantages, the following steps will prove its advantages!


Step 6: If you want to scale up the logical volume in the future, simply increase the capacity of the logical volume without formatting the volume. Therefore, the file on the Current Logical volume will not be lost, now you can perform a test to create a file (lvmtesting) on the created logical volume. The main goal is to check whether you need to reformat the logical volume after resizing, whether the created file will be lost, as shown in figure 7.


The lvml logical volume in this vdisk1 volume group is now expanded from 1 GB to 6 GB. The specific operations are as follows, -L + 1G indicates that the capacity is increased by 1G, and the logical volume added is affirmed using/dev/vdisk1/lvml.




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.