We often encounter such a situation. With the operation of the system, it is found that the remaining space of a certain partition is insufficient, so the partition needs to be expanded. How to expand it? A common strategy is to
-
Add a new hard disk, and then partition and format a new usable partition.
-
Copy the content of the previous file system to another partition, and then unmount the original partition (if the original file system is mounted in the /www directory)
-
Mount the new partition to the original directory /www, and then copy the previous content to the /www directory.
Does the whole process feel troublesome? If the original file system space is very large, dozens of G or even hundreds of G, then it will be a big project quantity. In addition, the previous partition has no use for the time being, and it is also a waste!
lvm introduction
lvm logical volume is used to solve the above problems Yes, it can be very convenient to scale the size of the file system. For lvm, there are several special terms that need to be known:
-
Physical Volume, referred to as PV: physical volume
-
Volume Group, referred to as VG: Logical Volume Group
-
Logical Volume, referred to as LV: Logical Volume
-
Physical Extent, PE for short: The smallest storage unit that can be allocated in (physical volume) is called PE, and the size of PE can be specified.
For the relationship between PV, VG, and LV, you can understand it through the following figure
lvm usage process
Let’s look at the lvm usage process, which is mainly divided into the following stages:
-
Disk partition
-
Use partition to make pv
-
Create vg from pv
-
Split lv from vg
-
Format lv and Mount to the directory and use
Disk partition This step is the same as before, use fdisk or gdisk tools to partition. The next step is the process of creating pv. This step is also simple, and there is a special tool pvcreate to create it. Like the pv process, there are also special vgcreate and lvcreate tools used in the vg stage and lv stage. The elastic expansion and contraction of the size of the file system is achieved by adjusting the size of lv.
In fact, the use of lvm is very simple, mainly in understanding the above proper nouns, and after understanding, it can be applied flexibly. Next, several articles will be prepared to introduce some commands of lvm and practical demonstrations.
For more related technical articles, please visit the Linux System Tutorial column!
The above is the introduction of lvm software under linux – the detailed content of the size of the flexible file system. For more information, please pay attention to other related articles on 1024programmer.com!