LVM——基本概念
介绍
LVM(Logical Volume Management)是一种存储设备管理技术,它赋予用户权力,汇集和抽象物理存储设备,从而实现更轻松,更灵活的管理。 利用device mapper这个Linux内核框架,当前迭代版本LVM2,可将现有存储设备收集到组中,并根据需要从组合空间分配逻辑单元。LVM的主要优点是增加了abstraction, flexibility, and control。 逻辑卷可以具有有意义的名称,如“数据库 (databases)”或“根备份 (root-backup)”。 当空间需求改变时,可以动态调整卷大小。在正在运行的系统上,存储的池中的物理设备之间也可以进行卷的迁移。 LVM还提供高级功能,如快照,分条和镜像。
LVM存储管理结构
LVM通过在物理存储设备之上分层抽象来实现功能。 LVM使用的基本层包括:
- Physical Volumes:
- LVM utility prefix: pv...
- Description: Physical block devices or other disk-like devices (for example, other devices created by device mapper, like RAID arrays) are used by LVM as the raw building material for higher levels of abstraction. Physical volumes are regular storage devices. LVM writes a header to the device to allocate it for management.
- Volume Groups:
- LVM utility prefix: vg...
- Description: LVM combines physical volumes into storage pools known as volume groups. Volume groups abstract the characteristics of the underlying devices and function as a unified logical device with combined storage capacity of the component physical volumes.
- Logical Volumes:
- LVM utility prefix: lv... (generic LVM utilities might begin with lvm...)
- Description: A volume group can be sliced up into any number of logical volumes. Logical volumes are functionally equivalent to partitions on a physical disk, but with much more flexibility. Logical volumes are the primary component that users and applications will interact with.
In summary, LVM can be used to combine physical volumes into volume groups to unify the storage space available on a system. Afterwards, administrators can segment the volume group into arbitrary logical volumes, which act as flexible partitions.
![](https://images2018.cnblogs.com/blog/383260/201805/383260-20180509165226932-1981642217.png)
Extents
卷组中的每个卷都被分割成固定大小的小块,称为extents。 extents的大小由卷组决定(组中的所有卷的extents大小相同)。
物理卷上的extents称为physical extents,而逻辑卷的extents称为logical extents。 逻辑卷仅仅是LVM在logical extents和physical extents之间维护的映射。 鉴于这种映射关系,extents大小代表LVM可以分配的最小空间。
LVM向上呈现的物理设备其logical extents是连续的,但真实情况对应的physical extents却可以是分散的。
LVM可以复制和重新组织构成逻辑卷的physical extents,而不会对用户造成任何中断。 通过在逻辑卷上添加或删除extents,也可以轻松扩展或收缩逻辑卷。
![](https://images2018.cnblogs.com/blog/383260/201805/383260-20180509165431347-801996039.png)