5.8.2. 对象选择
这部分提供了一组列表,表中列出的有关 LVM 对象的信息您可以用
pvs、vgs 和 lvs 命令获得。
为方便起见,字段名称前缀如果与命令默认字段匹配就可以去掉。例如:在
pvs 命令中,name 的指的是 pv_name,但使用 vgs 命令时,name 被理解为 vg_name。
执行以下命令和执行
pvs -o pv_free 的结果相同。
注意
The number of characters in the attribute fields in
pvs, vgs, and lvs output may increase in later releases. The existing character fields will not change position, but new fields may be added to the end. You should take this into account when writing scripts that search for particular attribute characters, searching for the character based on its relative position to the beginning of the field, but not for its relative position to the end of the field. For example, to search for the character p in the ninth bit of the lv_attr field, you could search for the string "^/........p/", but you should not search for the string "/*p$/".
pvs 命令 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
表 5.2 “pvs 显示字段” lists the display arguments of the
pvs command, along with the field name as it appears in the header display and a description of the field.
| 参数 | 标题 | 描述 |
|---|---|---|
dev_size | DevSize | 创建物理卷的基本设备的大小 |
pe_start | 1st PE | 在基本设备中调整到第一个物理扩展的起始位置 |
pv_attr | Attr | 物理卷状态:可分配(a)或者导出的(x)。 |
pv_fmt | Fmt | The metadata format of the physical volume (lvm2 or lvm1) |
pv_free | PFree | 物理卷中剩余的可用空间 |
pv_name | PV | 物理卷名称 |
pv_pe_alloc_count | Alloc | 已经使用的物理扩展数目 |
pv_pe_count | PE | 物理扩展数量 |
pvseg_size | SSize | 物理卷的片段大小 |
pvseg_start | Start | 物理卷片段的起始物理扩展 |
pv_size | PSize | 物理卷的大小 |
pv_tags | PV Tags | 附加到物理卷的 LVM 标签 |
pv_used | Used | 目前物理卷中已经使用的空间量 |
pv_uuid | PV UUID | 物理卷的 UUID |
默认情况下
pvs 命令显示以下字段:pv_name、vg_name、pv_fmt、pv_attr、pv_size、pv_free。结果根据 pv_name 排序。
使用带
-v 参数的 pvs 命令向默认显示中添加以下字段:dev_size、pv_uuid。
您可以使用
pvs 命令的 --segments 参数显示每个物理卷片段的信息。一个片段就是一组扩展。查看片段在想要查看逻辑卷是否有很多碎片时很有用。
pvs --segments 命令默认显示以下字段:pv_name、vg_name、pv_fmt、pv_attr、pv_size、pv_free、pvseg_start、pvseg_size。结果按照物理卷中 pv_name 和 pvseg_size 排序。
您可以使用
pvs -a 查看被 LVM 侦测出来但还没有初始化为 LVM 物理卷的设备。
vgs 命令 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
表 5.3 “vgs 显示字段” lists the display arguments of the
vgs command, along with the field name as it appears in the header display and a description of the field.
| 参数 | 标题 | 描述 |
|---|---|---|
lv_count | #LV | 卷组中含有的逻辑卷数目 |
max_lv | MaxLV | 卷组中最多可用逻辑卷数量(如果没有限制就是 0) |
max_pv | MaxPV | 卷组中最多允许的物理卷数目(如果没有限制就是 0) |
pv_count | #PV | 定义卷组的物理卷数目 |
snap_count | #SN | 卷组包含的快照数目 |
vg_attr | Attr | 卷组状态:可写入(w)、只读(r)、可重新定义大小(z)、导出的(x)、不完整的(p)和群集的(c)。 |
vg_extent_count | #Ext | 卷组中的物理扩展数目 |
vg_extent_size | Ext | 卷组中物理扩展的大小 |
vg_fmt | Fmt | The metadata format of the volume group (lvm2 or lvm1) |
vg_free | VFree | 卷组中剩余可用空间 |
vg_free_count | Free | 卷组中可用物理扩展数目 |
vg_name | VG | 卷组名称 |
vg_seqno | Seq | 代表修正卷组的数字 |
vg_size | VSize | 卷组大小 |
vg_sysid | SYS ID | LVM1 系统 ID |
vg_tags | VG Tags | 附加到卷组中的 LVM 标签 |
vg_uuid | VG UUID | 卷组的 UUID |
vgs 命令默认显示以下字段:vg_name、pv_count、lv_count、snap_count、vg_attr、vg_size、vg_free,并根据 vg_name 排序。
vgs
# vgs
VG #PV #LV #SN Attr VSize VFree
new_vg 3 1 1 wz--n- 51.42G 51.36G
使用带
-v 参数的 vgs 命令向默认显示中添加以下字段:vg_extent_size、vg_uuid。
lvs 命令 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
表 5.4 “lvs 显示字段” lists the display arguments of the
lvs command, along with the field name as it appears in the header display and a description of the field.
| 参数 | 标题 | 描述 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chunk | 快照卷的单位大小 | ||||||||||
copy_percent | Copy% | 镜像卷的同步化比例,还可在使用 pv_move 命令移动物理扩展时使用。 | ||||||||||
devices | Devices | 组成逻辑卷的基本设备:物理卷、逻辑卷以及起始物理和逻辑扩展 | ||||||||||
lv_attr | Attr | 逻辑卷状态。逻辑卷属性字节如下:
| ||||||||||
lv_kernel_major | KMaj | 逻辑卷的真实主设备号码(如果是未激活就减 1) | ||||||||||
lv_kernel_minor | KMIN | 逻辑卷的真实副设备号码(如果是未激活就减 1) | ||||||||||
lv_major | Maj | 逻辑卷持久的主设备号码(如果未指定就减 1) | ||||||||||
lv_minor | Min | 逻辑卷持久的副设备号码(如果未指定就减 1) | ||||||||||
lv_name | LV | 逻辑卷名称 | ||||||||||
lv_size | LSize | 逻辑卷的大小 | ||||||||||
lv_tags | LV Tags | 附加到逻辑卷的 LV 标签 | ||||||||||
lv_uuid | LV UUID | 逻辑卷的 UUID | ||||||||||
mirror_log | Log | 镜像分支所在设备 | ||||||||||
modules | Modules | 使用此逻辑卷符合内核设备映射器目标需要 | ||||||||||
move_pv | Move | 用 pvmove 命令创建的临时逻辑卷的源物理卷 | ||||||||||
origin | Origin | 快照卷的源设备 | ||||||||||
| Region | 镜像逻辑卷的单元大小 | ||||||||||
seg_count | #Seg | 逻辑卷中片段的数目 | ||||||||||
seg_size | SSize | 逻辑卷中片段的大小 | ||||||||||
seg_start | Start | 修正逻辑卷中的片段 | ||||||||||
seg_tags | Seg Tags | 附加到逻辑卷片段的 LVM 标签 | ||||||||||
segtype | Type | 逻辑卷的片段类型(例如:镜像、条状、线性) | ||||||||||
snap_percent | Snap% | 已经使用的快照卷的比例 | ||||||||||
stripes | #Str | 逻辑卷中条带或者镜像的数目 | ||||||||||
| Stripe | 条状逻辑卷中条带的单位大小 |
The
lvs command displays the following fields by default: lv_name, vg_name, lv_attr, lv_size, origin, snap_percent, move_pv, mirror_log, copy_percent, convert_lv. The default display is sorted by vg_name and lv_name within the volume group.
lvs
# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvol0 new_vg owi-a- 52.00M
newvgsnap1 new_vg swi-a- 8.00M lvol0 0.20
使用带
-v 参数的 lvs 命令在默认显示结果中添加以下字段:seg_count、lv_major、lv_minor、lv_kernel_major、lv_kernel_minor、lv_uuid。
您可以使用
lvs 命令的 --segments 参数显示强调片段信息的默认列。当您使用 segments 参数时,seg 前缀是可选的。lvs --segments 命令默认显示以下字段:lv_name、vg_name、lv_attr、stripes、segtype、seg_size。默认显示根据卷组的 vg_name 和 lv_name 排序。如果逻辑卷中有碎片,那么会在此命令的输出结果中显示出来。
使用带
-v 参数的 lvs --segments 命令向默认显示中添加以下字段:seg_start、stripesize、chunksize。
下面的例子显示在配置了一个逻辑卷的系统的
lvs 命令的默认输出结果以及指定了 segments 参数的 lvs 命令输出结果。