LVM commands

┬áJust some commands for working with LVM’s

[root@localhost ~]# lvdisplay | awk  '/LV Path/{n=$3} /Block device/{d=$3; sub(".*:","dm-",d); print d,n;}'
dm-0 /dev/centos/swap dm-1 /dev/centos/root dm-2 /dev/vg_data/lv_data

[root@localhost ~]# dmsetup ls
vg_data-lv_data (253:2)
centos-swap     (253:0)
centos-root     (253:1)
[root@localhost ~]# pvs
  PV         VG      Fmt  Attr PSize   PFree
  /dev/md1   vg_data lvm2 a--    7.28t    0
  /dev/sdg2  centos  lvm2 a--  135.48g    0
[root@localhost ~]# lvs
  LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root    centos  -wi-ao---- 121.88g                                       
  swap    centos  -wi-ao----  13.60g                                       
  lv_data vg_data -wi-ao----   7.28t  PV /dev/sdg2   VG centos    lvm2 [135.48 GiB / 0    free]
  PV /dev/md1    VG vg_data   lvm2 [7.28 TiB / 0    free]
  Total: 2 [7.41 TiB] / in use: 2 [7.41 TiB] / in no VG: 0 [0   ]
[root@localhost ~]# vgs
  VG      #PV #LV #SN Attr   VSize   VFree
  centos    1   2   0 wz--n- 135.48g    0
  vg_data   1   1   0 wz--n-   7.28t    0
[root@localhost ~]# pvscan
  PV /dev/sdg2   VG centos    lvm2 [135.48 GiB / 0    free]
  PV /dev/md1    VG vg_data   lvm2 [7.28 TiB / 0    free]
  Total: 2 [7.41 TiB] / in use: 2 [7.41 TiB] / in no VG: 0 [0   ]
[root@localhost ~]# lvscan
  ACTIVE            '/dev/centos/swap' [13.60 GiB] inherit
  ACTIVE            '/dev/centos/root' [121.88 GiB] inherit
  ACTIVE            '/dev/vg_data/lv_data' [7.28 TiB] inherit
[root@localhost ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "centos" using metadata type lvm2
  Found volume group "vg_data" using metadata type lvm2
[root@localhost ~]# pvdisplay
[root@localhost ~]# vgdisplay
[root@localhost ~]# lvdisplay

Leave a Reply