LVM 管理:格式化输出

小编 2026-07-05 阅读:737 评论:0
 今天学习了下 LVM 输出格式化的内容,显示LVM信息常用 pvs,lvs,vgs 命令,如果想显示  详细信息可以使用 pvdisplay ,vgdisplay ,lvdisplay,其中前面命令仅用于...

 今天学习了下 LVM 输出格式化的内容,显示LVM信息常用 pvs,lvs,vgs 命令,如果想显示
 详细信息可以使用 pvdisplay ,vgdisplay ,lvdisplay,其中前面命令仅用于简单输出 lvm 对
 象相关信息,可以格式化输出;第二种命令会详细显示 lvm 对像信息,但不易于格式化输出。 

 

一 pvs,lvs vgs 使用
--1.1 显示物理卷(pv)信息

 

 [root@redhat6 lvm]# pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  vg_redhat6 lvm2 a--  14.51g    0 
  /dev/sdb   vg_redhat6 lvm2 a--   4.00g 2.81g

 

 

--1.2 显示逻辑卷组(vg)信息                                 

 

 [root@redhat6 lvm]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree
  vg_redhat6   2   3   0 wz--n- 18.50g 2.81g

   

 

 

--1.3显示逻辑卷(lv)信息

 

 [root@redhat6 lvm]# lvs
  LV           VG         Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv_pgdata_01 vg_redhat6 -wi-ao 700.00m                                      
  lv_root      vg_redhat6 -wi-ao  13.10g                                      
  lv_swap      vg_redhat6 -wi-ao   1.91g   

   
        备注:前面的 pvs,lvs,vgs 命令简单显示 LVM 对像信息,都是默认的输出。      

 

 

二 格式化控制
--2.1 显示额外信息

 

 

 [root@redhat6 lvm]# pvs -v
    Scanning for physical volume names
  PV         VG         Fmt  Attr PSize  PFree DevSize PV UUID                               
  /dev/sda2  vg_redhat6 lvm2 a--  14.51g    0   14.51g dpTW84-DHRy-PIA9-u1tY-YUH4-XQKw-8Hy2Zm
  /dev/sdb   vg_redhat6 lvm2 a--   4.00g 2.81g   4.00g YKIQwX-zc6H-TZ65-P3qr-sRfk-LX0p-T18vdG
  
[root@redhat6 lvm]# vgs -v
    Finding all volume groups
    Finding volume group \"vg_redhat6\"
  VG         Attr   Ext   #PV #LV #SN VSize  VFree VG UUID                               
  vg_redhat6 wz--n- 4.00m   2   3   0 18.50g 2.81g E6cA2U-TL1x-ScCV-UnGU-3Kq4-1u6V-WUb5L4

 

      备注:增加 -v 参数,会显示LVM 对像的额外信息,例如 UUID字段。
 
--2.2 pvs 默认输出

 

 [root@redhat6 lvm]# pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  vg_redhat6 lvm2 a--  14.51g    0 
  /dev/sdb   vg_redhat6 lvm2 a--   4.00g 2.81g

 

   
  
--2.3 只显示 pv_name,dev_size 字段

 

 [root@redhat6 lvm]# pvs -o pv_name,dev_size
  PV         DevSize
  /dev/sda2   14.51g
  /dev/sdb     4.00g   

 

     备注:增加 -o 参数,指定需要输出的字段。
  
--2.4 在pvs 默认输出上,增加字段

 

 [root@redhat6 lvm]# pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  vg_redhat6 lvm2 a--  14.51g    0 
  /dev/sdb   vg_redhat6 lvm2 a--   4.00g 2.81g

[root@redhat6 lvm]# pvs -o +pv_uuid
  PV         VG         Fmt  Attr PSize  PFree PV UUID                               
  /dev/sda2  vg_redhat6 lvm2 a--  14.51g    0  dpTW84-DHRy-PIA9-u1tY-YUH4-XQKw-8Hy2Zm
  /dev/sdb   vg_redhat6 lvm2 a--   4.00g 2.81g YKIQwX-zc6H-TZ65-P3qr-sRfk-LX0p-T18vdG 

 

     备注:如果想在默认输出的前提下增加字段,可以使用 -o + 字段名。
 

--2.5 vgs 显示卷组成员

 [root@redhat6 lvm]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree
  vg_redhat6   2   3   0 wz--n- 18.50g 2.81g
  
[root@redhat6 lvm]# vgs -o +lv_name
  VG         #PV #LV #SN Attr   VSize  VFree LV          
  vg_redhat6   2   3   0 wz--n- 18.50g 2.81g lv_root     
  vg_redhat6   2   3   0 wz--n- 18.50g 2.81g lv_swap     
  vg_redhat6   2   3   0 wz--n- 18.50g 2.81g lv_pgdata_01  

    

 

 

三 字段排序  
--3.1 根据 lv_size 字段排序

 

 [root@redhat6 lvm]# lvs
  LV           VG         Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv_pgdata_01 vg_redhat6 -wi-ao 700.00m                                      
  lv_root      vg_redhat6 -wi-ao  13.10g                                      
  lv_swap      vg_redhat6 -wi-ao   1.91g                                     

[root@redhat6 lvm]# lvs -O lv_size
  LV           VG         Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv_pgdata_01 vg_redhat6 -wi-ao 700.00m                                      
  lv_swap      vg_redhat6 -wi-ao   1.91g                                      
  lv_root      vg_redhat6 -wi-ao  13.10g  

     备注:如果想根据输出字段排序,可以使用 -O 字段名 选项。
  
四附 lvs,vgs,pvs 字段
--4.1 lvs 字段

  ---------------------
    lv_all               - All fields in this section.
    lv_uuid              - Unique identifier.
    lv_name              - Name.  LVs created for internal use are enclosed in brackets.
    lv_path              - Full pathname for LV.
    lv_attr              - Various attributes - see man page.
    lv_major             - Persistent major number or -1 if not persistent.
    lv_minor             - Persistent minor number or -1 if not persistent.
    lv_read_ahead        - Read ahead setting in current units.
    lv_kernel_major      - Currently assigned major number or -1 if LV is not active.
    lv_kernel_minor      - Currently assigned minor number or -1 if LV is not active.
    lv_kernel_read_ahead - Currently-in-use read ahead setting in current units.
    lv_size              - Size of LV in current units.
    seg_count            - Number of segments in LV.
    origin               - For snapshots, the origin device of this LV.
    origin_size          - For snapshots, the size of the origin device of this LV.
    snap_percent         - For snapshots, the percentage full if LV is active.
    copy_percent         - For mirrors and pvmove, current percentage in-sync.
    move_pv              - For pvmove, Source PV of temporary LV created by pvmove.
    convert_lv           - For lvconvert, Name of temporary LV created by lvconvert.
    lv_tags              - Tags, if any.
    mirror_log           - For mirrors, the LV holding the synchronisation log.
    modules              - Kernel device-mapper modules required for this LV.
    
--4.2 pvs 字段
    pv_all               - All fields in this section.
    pe_start             - Offset to the start of data on the underlying device.
    pv_size              - Size of PV in current units.
    pv_free              - Total amount of unallocated space in current units.
    pv_used              - Total amount of allocated space in current units.
    pv_attr              - Various attributes - see man page.
    pv_pe_count          - Total number of Physical Extents.
    pv_pe_alloc_count    - Total number of allocated Physical Extents.
    pv_tags              - Tags, if any.
    pv_mda_count         - Number of metadata areas on this device.
    pv_mda_used_count    - Number of metadata areas in use on this device.
    
--4.3 vgs 字段
    vg_all               - All fields in this section.
    vg_fmt               - Type of metadata.
    vg_uuid              - Unique identifier.
    vg_name              - Name.
    vg_attr              - Various attributes - see man page.
    vg_size              - Total size of VG in current units.
    vg_free              - Total amount of free space in current units.
    vg_sysid             - System ID indicating when and where it was created.
    vg_extent_size       - Size of Physical Extents in current units.
    vg_extent_count      - Total number of Physical Extents.
    vg_free_count        - Total number of unallocated Physical Extents.
    max_lv               - Maximum number of LVs allowed in VG or 0 if unlimited.
    max_pv               - Maximum number of PVs allowed in VG or 0 if unlimited.
    pv_count             - Number of PVs.
    lv_count             - Number of LVs.
    snap_count           - Number of snapshots.
    vg_seqno             - Revision number of internal metadata.  Incremented whenever it changes.
    vg_tags              - Tags, if any.
    vg_mda_count         - Number of metadata areas on this VG.
    vg_mda_used_count    - Number of metadata areas in use on this VG.
    vg_mda_free          - Free metadata area space for this VG in current units.
    vg_mda_size          - Size of smallest metadata area for this VG in current units.
    vg_mda_copies        - Target number of in use metadata areas in the VG.          
   

版权声明

本文仅代表作者观点,不代表百度立场。
本文系作者授权百度百家发表,未经许可,不得转载。

热门文章
  • Sequential Monte Carlo Methods (SMC) 序列蒙特卡洛/粒子滤波/Bootstrap Filtering

    Sequential Monte Carlo Methods (SMC) 序列蒙特卡洛/粒子滤波/Bootstrap Filtering
    Problem Statement 我们考虑一个具有马尔可夫性质、非线性、非高斯的状态空间模型(State Space Model):对于一个时间序列上的观测结果{yt,t∈N}\\{ y_t , t \\in N \\}{yt​,t∈N},我们认为每个观测结果yty_tyt​的生成依赖于一个无法直接观察的隐变量xt∈{xt,t∈N}x_t \\in \\{x_t , t \\in N \\}xt​∈{xt​,t∈N},即:p(...
  • 机房智能化温湿度解决方式之POE供电以太网温湿度传感器

    机房智能化温湿度解决方式之POE供电以太网温湿度传感器
    机房智能化温湿度解决方式之POE供电以太网温湿度传感器 北京盈创力和电子科技有限公司 智能型TCP网口温湿度记录仪 北京IP网络温湿度记录仪厂家,北京盈创力和 北京智能型TCP网口温湿度记录仪IP网络温湿度记录仪是一种新型的基于TCP/IP协议双绞线以太网标准温湿度采集模块,利用它可以实现现场温度值、相对湿度值的采集,同时利用其自身的RJ45通信接口可以方便地和机房监控主机或交换机集线器进行联网。 工作于-40℃~85℃工业级带...
  • Hive 系统函数及示例

    Hive 系统函数及示例
    查看所有系统函数 show functions; 函数分类 内置函数【系统函数】 数学函数: floor、round、ceil、cos、log2等 字符串函数: length、reverse、trim、lower、get_json_object、repeat等 收集函数: size 转换函数: cast 日期函数: year、month、datediff、date、date_add等 条件函数: coalesce、case…w...
  • HTTP状态保持的原理

    HTTP状态保持的原理
    a)在用户登录之后,浏览器返回响应的时候会在响应中添加上cookieb)浏览器接收到cookie之后会自动保存c)当用户再次请求同一服务器中的其他网页的时候,浏览器会自动带上之前保存的cookied)服务接收到请求之后可以请 request 对象中取到cookie 判断当前用户是否登录  Http是无状态的,就是连接时数据互通,关闭后...
  • CSRF的原理和防范措施

    CSRF的原理和防范措施
    a)攻击原理:i.用户C访问正常网站A时进行登录,浏览器保存A的cookieii.用户C再访问攻击网站B,网站B上有某个隐藏的链接或者图片标签会自动请求网站A的URL地址,例如表单提交,传指定的参数iii.而攻击网站B在访问网站A的时候,浏览器会自动带上网站A的cookieiv.所以网站A在接收到请求之后可判断当前用户是登录状态,所以...
标签列表