5.8.2. 对象选择


这部分提供了一组列表,表中列出的有关 LVM 对象的信息您可以用 pvsvgslvs 命令获得。
为方便起见,字段名称前缀如果与命令默认字段匹配就可以去掉。例如:在 pvs 命令中,name 的指的是 pv_name,但使用 vgs 命令时,name 被理解为 vg_name
执行以下命令和执行 pvs -o pv_free 的结果相同。
# pvs -o free
  PFree
  17.14G
  17.09G
  17.14G
Copy to Clipboard Toggle word wrap

注意

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.
Expand
表 5.2. pvs 显示字段
参数标题描述
dev_sizeDevSize创建物理卷的基本设备的大小
pe_start1st PE在基本设备中调整到第一个物理扩展的起始位置
pv_attrAttr物理卷状态:可分配(a)或者导出的(x)。
pv_fmtFmt The metadata format of the physical volume (lvm2 or lvm1)
pv_freePFree物理卷中剩余的可用空间
pv_namePV 物理卷名称
pv_pe_alloc_countAlloc已经使用的物理扩展数目
pv_pe_countPE 物理扩展数量
pvseg_sizeSSize物理卷的片段大小
pvseg_startStart物理卷片段的起始物理扩展
pv_sizePSize物理卷的大小
pv_tagsPV Tags附加到物理卷的 LVM 标签
pv_usedUsed目前物理卷中已经使用的空间量
pv_uuidPV UUID物理卷的 UUID
默认情况下 pvs 命令显示以下字段:pv_namevg_namepv_fmtpv_attrpv_sizepv_free。结果根据 pv_name 排序。
# pvs
  PV         VG     Fmt  Attr PSize  PFree
  /dev/sdb1  new_vg lvm2 a-   17.14G 17.14G
  /dev/sdc1  new_vg lvm2 a-   17.14G 17.09G
  /dev/sdd1  new_vg lvm2 a-   17.14G 17.13G
Copy to Clipboard Toggle word wrap
使用带 -v 参数的 pvs 命令向默认显示中添加以下字段:dev_sizepv_uuid
# pvs -v
    Scanning for physical volume names
  PV         VG     Fmt  Attr PSize  PFree  DevSize PV UUID
  /dev/sdb1  new_vg lvm2 a-   17.14G 17.14G  17.14G onFF2w-1fLC-ughJ-D9eB-M7iv-6XqA-dqGeXY
  /dev/sdc1  new_vg lvm2 a-   17.14G 17.09G  17.14G Joqlch-yWSj-kuEn-IdwM-01S9-XO8M-mcpsVe
  /dev/sdd1  new_vg lvm2 a-   17.14G 17.13G  17.14G yvfvZK-Cf31-j75k-dECm-0RZ3-0dGW-tUqkCS
Copy to Clipboard Toggle word wrap
您可以使用 pvs 命令的 --segments 参数显示每个物理卷片段的信息。一个片段就是一组扩展。查看片段在想要查看逻辑卷是否有很多碎片时很有用。
pvs --segments 命令默认显示以下字段:pv_namevg_namepv_fmtpv_attrpv_sizepv_freepvseg_startpvseg_size。结果按照物理卷中 pv_namepvseg_size 排序。
# pvs --segments
  PV         VG         Fmt  Attr PSize  PFree  Start SSize
  /dev/hda2  VolGroup00 lvm2 a-   37.16G 32.00M     0  1172
  /dev/hda2  VolGroup00 lvm2 a-   37.16G 32.00M  1172    16
  /dev/hda2  VolGroup00 lvm2 a-   37.16G 32.00M  1188     1
  /dev/sda1  vg         lvm2 a-   17.14G 16.75G     0    26
  /dev/sda1  vg         lvm2 a-   17.14G 16.75G    26    24
  /dev/sda1  vg         lvm2 a-   17.14G 16.75G    50    26
  /dev/sda1  vg         lvm2 a-   17.14G 16.75G    76    24
  /dev/sda1  vg         lvm2 a-   17.14G 16.75G   100    26
  /dev/sda1  vg         lvm2 a-   17.14G 16.75G   126    24
  /dev/sda1  vg         lvm2 a-   17.14G 16.75G   150    22
  /dev/sda1  vg         lvm2 a-   17.14G 16.75G   172  4217
  /dev/sdb1  vg         lvm2 a-   17.14G 17.14G     0  4389
  /dev/sdc1  vg         lvm2 a-   17.14G 17.14G     0  4389
  /dev/sdd1  vg         lvm2 a-   17.14G 17.14G     0  4389
  /dev/sde1  vg         lvm2 a-   17.14G 17.14G     0  4389
  /dev/sdf1  vg         lvm2 a-   17.14G 17.14G     0  4389
  /dev/sdg1  vg         lvm2 a-   17.14G 17.14G     0  4389
Copy to Clipboard Toggle word wrap
您可以使用 pvs -a 查看被 LVM 侦测出来但还没有初始化为 LVM 物理卷的设备。
# pvs -a
  PV                             VG     Fmt  Attr PSize  PFree
  /dev/VolGroup00/LogVol01                   --       0      0
  /dev/new_vg/lvol0                          --       0      0
  /dev/ram                                   --       0      0
  /dev/ram0                                  --       0      0
  /dev/ram2                                  --       0      0
  /dev/ram3                                  --       0      0
  /dev/ram4                                  --       0      0
  /dev/ram5                                  --       0      0
  /dev/ram6                                  --       0      0
  /dev/root                                  --       0      0
  /dev/sda                                   --       0      0
  /dev/sdb                                   --       0      0
  /dev/sdb1                      new_vg lvm2 a-   17.14G 17.14G
  /dev/sdc                                   --       0      0
  /dev/sdc1                      new_vg lvm2 a-   17.14G 17.09G
  /dev/sdd                                   --       0      0
  /dev/sdd1                      new_vg lvm2 a-   17.14G 17.14G
Copy to Clipboard Toggle word wrap

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.
Expand
表 5.3. vgs 显示字段
参数标题描述
lv_count#LV 卷组中含有的逻辑卷数目
max_lvMaxLV卷组中最多可用逻辑卷数量(如果没有限制就是 0)
max_pvMaxPV卷组中最多允许的物理卷数目(如果没有限制就是 0)
pv_count#PV 定义卷组的物理卷数目
snap_count#SN 卷组包含的快照数目
vg_attrAttr卷组状态:可写入(w)、只读(r)、可重新定义大小(z)、导出的(x)、不完整的(p)和群集的(c)。
vg_extent_count#Ext卷组中的物理扩展数目
vg_extent_sizeExt 卷组中物理扩展的大小
vg_fmtFmt The metadata format of the volume group (lvm2 or lvm1)
vg_freeVFree卷组中剩余可用空间
vg_free_countFree卷组中可用物理扩展数目
vg_nameVG 卷组名称
vg_seqnoSeq 代表修正卷组的数字
vg_sizeVSize卷组大小
vg_sysidSYS IDLVM1 系统 ID
vg_tagsVG Tags附加到卷组中的 LVM 标签
vg_uuidVG UUID卷组的 UUID
vgs 命令默认显示以下字段:vg_namepv_countlv_countsnap_countvg_attrvg_sizevg_free,并根据 vg_name 排序。
# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  new_vg   3   1   1 wz--n- 51.42G 51.36G
Copy to Clipboard Toggle word wrap
使用带 -v 参数的 vgs 命令向默认显示中添加以下字段:vg_extent_sizevg_uuid
# vgs -v
    Finding all volume groups
    Finding volume group "new_vg"
  VG     Attr   Ext   #PV #LV #SN VSize  VFree  VG UUID
  new_vg wz--n- 4.00M   3   1   1 51.42G 51.36G jxQJ0a-ZKk0-OpMO-0118-nlwO-wwqd-fD5D32
Copy to Clipboard Toggle word wrap

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.
Expand
表 5.4. lvs 显示字段
参数标题描述
chunksize
chunk_size
Chunk快照卷的单位大小
copy_percentCopy%镜像卷的同步化比例,还可在使用 pv_move 命令移动物理扩展时使用。
devicesDevices组成逻辑卷的基本设备:物理卷、逻辑卷以及起始物理和逻辑扩展
lv_attrAttr逻辑卷状态。逻辑卷属性字节如下:
Bit 1: Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin, (O)rigin with merging snapshot, (r)aid, (R)aid without initial sync, (s)napshot, merging (S)napshot, (p)vmove, (v)irtual, mirror or raid (i)mage, mirror or raid (I)mage out-of-sync, mirror (l)og device, under (c)onversion, thin (V)olume, (t)hin pool, (T)hin pool data, raid or thin pool m(e)tadata or pool metadata spare,
Bit 2: Permissions: (w)riteable, (r)ead-only, (R)ead-only activation of non-read-only volume
Bit 3: Allocation policy: (a)nywhere, (c)ontiguous, (i)nherited, c(l)ing, (n)ormal. This is capitalized if the volume is currently locked against allocation changes, for example while executing the pvmove command.
字节 4:固定的副号码(m)
Bit 5: State: (a)ctive, (s)uspended, (I)nvalid snapshot, invalid (S)uspended snapshot, snapshot (m)erge failed, suspended snapshot (M)erge failed, mapped (d)evice present without tables, mapped device present with (i)nactive table
字节 6:设备开放(o)
Bit 7: Target type: (m)irror, (r)aid, (s)napshot, (t)hin, (u)nknown, (v)irtual. This groups logical volumes related to the same kernel target together. So, for example, mirror images, mirror logs as well as mirrors themselves appear as (m) if they use the original device-mapper mirror kernel driver, whereas the raid equivalents using the md raid kernel driver all appear as (r). Snapshots using the original device-mapper driver appear as (s), whereas snapshots of thin volumes using the thin provisioning driver appear as (t).
Bit 8: Newly-allocated data blocks are overwritten with blocks of (z)eroes before use.
Bit 9: Volume Health: (p)artial, (r)efresh needed, (m)ismatches exist, (w)ritemostly. (p)artial signifies that one or more of the Physical Volumes this Logical Volume uses is missing from the system. (r)efresh signifies that one or more of the Physical Volumes this RAID Logical Volume uses had suffered a write error. The write error could be due to a temporary failure of that Physical Volume or an indication that it is failing. The device should be refreshed or replaced. (m)ismatches signifies that the RAID logical volume has portions of the array that are not coherent. Inconsistencies are discovered by initiating a check operation on a RAID logical volume. (The scrubbing operations, check and repair, can be performed on a RAID Logical Volume by means of the lvchange command.) (w)ritemostly signifies the devices in a RAID 1 logical volume that have been marked write-mostly.
Bit 10: s(k)ip activation: this volume is flagged to be skipped during activation.
lv_kernel_majorKMaj逻辑卷的真实主设备号码(如果是未激活就减 1)
lv_kernel_minorKMIN逻辑卷的真实副设备号码(如果是未激活就减 1)
lv_majorMaj 逻辑卷持久的主设备号码(如果未指定就减 1)
lv_minorMin 逻辑卷持久的副设备号码(如果未指定就减 1)
lv_nameLV 逻辑卷名称
lv_sizeLSize逻辑卷的大小
lv_tagsLV Tags附加到逻辑卷的 LV 标签
lv_uuidLV UUID逻辑卷的 UUID
mirror_logLog 镜像分支所在设备
modulesModules使用此逻辑卷符合内核设备映射器目标需要
move_pvMovepvmove 命令创建的临时逻辑卷的源物理卷
originOrigin快照卷的源设备
regionsize
region_size
Region镜像逻辑卷的单元大小
seg_count#Seg逻辑卷中片段的数目
seg_sizeSSize逻辑卷中片段的大小
seg_startStart修正逻辑卷中的片段
seg_tagsSeg Tags附加到逻辑卷片段的 LVM 标签
segtypeType逻辑卷的片段类型(例如:镜像、条状、线性)
snap_percentSnap%已经使用的快照卷的比例
stripes#Str逻辑卷中条带或者镜像的数目
stripesize
stripe_size
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
  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
Copy to Clipboard Toggle word wrap
使用带 -v 参数的 lvs 命令在默认显示结果中添加以下字段:seg_countlv_majorlv_minorlv_kernel_majorlv_kernel_minorlv_uuid
# lvs -v
    Finding all logical volumes
  LV         VG     #Seg Attr   LSize  Maj Min KMaj KMin Origin Snap%  Move Copy%  Log Convert LV UUID
  lvol0      new_vg    1 owi-a- 52.00M  -1  -1 253  3                                          LBy1Tz-sr23-OjsI-LT03-nHLC-y8XW-EhCl78
  newvgsnap1 new_vg    1 swi-a-  8.00M  -1  -1 253  5    lvol0    0.20                         1ye1OU-1cIu-o79k-20h2-ZGF0-qCJm-CfbsIx
Copy to Clipboard Toggle word wrap
您可以使用 lvs 命令的 --segments 参数显示强调片段信息的默认列。当您使用 segments 参数时,seg 前缀是可选的。lvs --segments 命令默认显示以下字段:lv_namevg_namelv_attrstripessegtypeseg_size。默认显示根据卷组的 vg_namelv_name 排序。如果逻辑卷中有碎片,那么会在此命令的输出结果中显示出来。
# lvs --segments
  LV       VG         Attr   #Str Type   SSize
  LogVol00 VolGroup00 -wi-ao    1 linear  36.62G
  LogVol01 VolGroup00 -wi-ao    1 linear 512.00M
  lv       vg         -wi-a-    1 linear 104.00M
  lv       vg         -wi-a-    1 linear 104.00M
  lv       vg         -wi-a-    1 linear 104.00M
  lv       vg         -wi-a-    1 linear  88.00M
Copy to Clipboard Toggle word wrap
使用带 -v 参数的 lvs --segments 命令向默认显示中添加以下字段:seg_startstripesizechunksize
# lvs -v --segments
    Finding all logical volumes
  LV         VG     Attr   Start SSize  #Str Type   Stripe Chunk
  lvol0      new_vg owi-a-    0  52.00M    1 linear     0     0
  newvgsnap1 new_vg swi-a-    0   8.00M    1 linear     0  8.00K
Copy to Clipboard Toggle word wrap
下面的例子显示在配置了一个逻辑卷的系统的 lvs 命令的默认输出结果以及指定了 segments 参数的 lvs 命令输出结果。
# lvs
  LV    VG     Attr   LSize  Origin Snap%  Move Log Copy%
  lvol0 new_vg -wi-a- 52.00M
# lvs --segments
  LV    VG     Attr   #Str Type   SSize
  lvol0 new_vg -wi-a-    1 linear 52.00M
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat