Wise people learn when they can; fools learn when they must - Arthur Wellesley

Saturday, 1 April 2017

RHEL6-18-LOGICAL VOLUME MANAGER (LVM)-5


RHEL6-18-LOGICAL VOLUME MANAGER (LVM)-5


LVM OPERATIONS:

How to remove logical volume (LV)?
How to remove volume group (VG)?
How to remove physical volume (PV)?
How to free the disk by moving data to another disk in LVM?
How to remove the free/unused disk in LVM?

LVREMOVE:

[root@rhel6-client1 ~]# lvs
  LV            VG        Attr      LSize   Pool Origin Data%  Move Log                Cpy%Sync Convert
  mylv01        myvg01    -wi-a---- 200.00m
  mymirrorvol01 myvg01    mwi-a-m-- 100.00m                         mymirrorvol01_mlog   100.00
  mymirrorvol02 myvg01    mwi-a-m-- 100.00m                         mymirrorvol02_mlog   100.00
  mystripevol01 myvg01    -wi-a---- 104.00m
  lv02          vg-test01 -wi-a----   2.00g
  lvol0         vg-test01 -wi-a---- 700.00m
  mylv2         vg-test01 -wi-a----   3.39g
  mylvtest1     vg-test01 -wi-ao---   1.46g

[root@rhel6-client1 ~]# lvremove /dev/vg-test01/lv02 /dev/vg-test01/lvol0 /dev/vg-test01/mylv2 /dev/vg-test01/mylvtest1
Do you really want to remove active logical volume lvol0? [y/n]: y
  Logical volume "lvol0" successfully removed
Do you really want to remove active logical volume lv02? [y/n]: y
  Logical volume "lv02" successfully removed
  Logical volume vg-test01/mylvtest1 contains a filesystem in use.
Do you really want to remove active logical volume mylv2? [y/n]: y
  Logical volume "mylv2" successfully removed

[root@rhel6-client1 ~]# lvs
  LV            VG        Attr      LSize   Pool Origin Data%  Move Log                Cpy%Sync Convert
  mylv01        myvg01    -wi-a---- 200.00m
  mymirrorvol01 myvg01    mwi-a-m-- 100.00m                         mymirrorvol01_mlog   100.00
  mymirrorvol02 myvg01    mwi-a-m-- 100.00m                         mymirrorvol02_mlog   100.00
  mystripevol01 myvg01    -wi-a---- 104.00m
  mylvtest1     vg-test01 -wi-ao---   1.46g

[root@rhel6-client1 ~]# lvremove /dev/vg-test01/mylvtest1
  Logical volume vg-test01/mylvtest1 contains a filesystem in use.

[root@rhel6-client1 ~]# df -kh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda6              15G  6.3G  7.4G  46% /
tmpfs                 937M   76K  937M   1% /dev/shm
/dev/sda1             485M   37M  423M   8% /boot
/dev/sda3            1008M   34M  924M   4% /home
/dev/sda2             2.9G   69M  2.7G   3% /opt
/dev/mapper/vg--test01-mylvtest1
                      1.5G   35M  1.4G   3% /mylv

[root@rhel6-client1 ~]# umount /mylv

[root@rhel6-client1 ~]# lvremove /dev/vg-test01/mylvtest1
Do you really want to remove active logical volume mylvtest1? [y/n]: y
  Logical volume "mylvtest1" successfully removed

[root@rhel6-client1 ~]# lvs
  LV            VG     Attr      LSize   Pool Origin Data%  Move Log                Cpy%Sync Convert
  mylv01        myvg01 -wi-a---- 200.00m
  mymirrorvol01 myvg01 mwi-a-m-- 100.00m                         mymirrorvol01_mlog   100.00
  mymirrorvol02 myvg01 mwi-a-m-- 100.00m                         mymirrorvol02_mlog   100.00
  mystripevol01 myvg01 -wi-a---- 104.00m

VGREMOVE:

[root@rhel6-client1 ~]# vgremove myvg01 vg-test01 vg02
  Volume group "myvg01" successfully removed
  Volume group "vg-test01" successfully removed
  Volume group "vg02" successfully removed

PVREMOVE:

[root@rhel6-client1 ~]# pvs
  PV         VG   Fmt  Attr PSize PFree
  /dev/sdb1       lvm2 a--  5.00g 5.00g
  /dev/sdb2       lvm2 a--  3.00g 3.00g
  /dev/sdb3       lvm2 a--  2.00g 2.00g
  /dev/sdb4       lvm2 a--  1.00g 1.00g
  /dev/sdc1       lvm2 a--  5.00g 5.00g
  /dev/sdc2       lvm2 a--  2.00g 2.00g
  /dev/sdc3       lvm2 a--  3.00g 3.00g
  /dev/sdd1       lvm2 a--  2.00g 2.00g
  /dev/sdd2       lvm2 a--  1.00g 1.00g
  /dev/sdd3       lvm2 a--  2.00g 2.00g
  /dev/sdd5       lvm2 a--  2.00g 2.00g

[root@rhel6-client1 ~]# pvremove /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb4 /dev/sdc1
  Labels on physical volume "/dev/sdb1" successfully wiped
  Labels on physical volume "/dev/sdb2" successfully wiped
  Labels on physical volume "/dev/sdb3" successfully wiped
  Labels on physical volume "/dev/sdb4" successfully wiped
  Labels on physical volume "/dev/sdc1" successfully wiped

[root@rhel6-client1 ~]# pvs
  PV         VG   Fmt  Attr PSize PFree
  /dev/sdc2       lvm2 a--  2.00g 2.00g
  /dev/sdc3       lvm2 a--  3.00g 3.00g
  /dev/sdd1       lvm2 a--  2.00g 2.00g
  /dev/sdd2       lvm2 a--  1.00g 1.00g
  /dev/sdd3       lvm2 a--  2.00g 2.00g
  /dev/sdd5       lvm2 a--  2.00g 2.00g

[root@rhel6-client1 ~]# pvremove /dev/sdc2 /dev/sdc3
  Labels on physical volume "/dev/sdc2" successfully wiped
  Labels on physical volume "/dev/sdc3" successfully wiped

[root@rhel6-client1 ~]# lvs
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv01Fvg01     vg01 -wi-a---- 500.00m
  lv02Fvg01     vg01 -wi-a---- 300.00m
  testlv01Fvg02 vg02 -wi-a---- 300.00m
  testlv02Fvg02 vg02 -wi-a---- 400.00m

DISK REMOVAL / MOVE THE DATA AND REMOVE THE DISK:

[root@rhel6-client1 ~]# mkdir /lv01Fvg01
[root@rhel6-client1 ~]# mkdir /lv02Fvg01
[root@rhel6-client1 ~]# mkdir /testlv01Fvg02
[root@rhel6-client1 ~]# mkdir /testlv02Fvg02
[root@rhel6-client1 ~]# mount /dev/vg01/lv01Fvg01 /lv01Fvg01
[root@rhel6-client1 ~]# mount /dev/vg01/lv02Fvg01 /lv02Fvg01
[root@rhel6-client1 ~]# mount /dev/vg02/testlv01Fvg02 /testlv01Fvg02
[root@rhel6-client1 ~]# mount /dev/vg02/testlv02Fvg02 /testlv02Fvg02
[root@rhel6-client1 ~]# df -kh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda6              15G  6.3G  7.4G  46% /
tmpfs                 937M   76K  937M   1% /dev/shm
/dev/sda1             485M   37M  423M   8% /boot
/dev/sda3            1008M   34M  924M   4% /home
/dev/sda2             2.9G   69M  2.7G   3% /opt
/dev/mapper/vg01-lv01Fvg01
                      485M   11M  449M   3% /lv01Fvg01
/dev/mapper/vg01-lv02Fvg01
                      291M   11M  266M   4% /lv02Fvg01
/dev/mapper/vg02-testlv01Fvg02
                      291M   11M  266M   4% /testlv01Fvg02
/dev/mapper/vg02-testlv02Fvg02
                      388M   11M  358M   3% /testlv02Fvg02
[root@rhel6-client1 ~]#

Now I want to remove the free space or unused disk.

[root@rhel6-client1 ~]# lvs -a -o +devices
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert Devices
  lv01Fvg01     vg01 -wi-ao--- 500.00m                                              /dev/sdd1(0)
  lv02Fvg01     vg01 -wi-ao--- 300.00m                                              /dev/sdd1(125)
  testlv01Fvg02 vg02 -wi-ao--- 300.00m                                              /dev/sdd3(0)
  testlv02Fvg02 vg02 -wi-ao--- 400.00m                                              /dev/sdd3(75)

[root@rhel6-client1 ~]# pvs  -a -o +devices |egrep "vg01|vg02"
PV                      VG   Fmt  Attr PSize    PFree    Devices
  /dev/sdd1               vg01 lvm2 a--     2.00g    1.21g /dev/sdd1(0)
  /dev/sdd1               vg01 lvm2 a--     2.00g    1.21g /dev/sdd1(125)
  /dev/sdd1               vg01 lvm2 a--     2.00g    1.21g
  /dev/sdd2               vg01 lvm2 a--  1020.00m 1020.00m
  /dev/sdd3               vg02 lvm2 a--     2.00g    1.31g /dev/sdd3(0)
  /dev/sdd3               vg02 lvm2 a--     2.00g    1.31g /dev/sdd3(75)
  /dev/sdd3               vg02 lvm2 a--     2.00g    1.31g
  /dev/sdd5               vg02 lvm2 a--     2.00g    2.00g

Getting something…? Or some more explanation required…?

Ok,

We have the PV, LV and VG size.

[root@rhel6-client1 ~]# pvs
  PV         VG   Fmt  Attr PSize    PFree
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g

[root@rhel6-client1 ~]# vgs
  VG   #PV #LV #SN Attr   VSize VFree
  vg01   2   2   0 wz--n- 2.99g 2.21g
  vg02   2   2   0 wz--n- 3.99g 3.31g

[root@rhel6-client1 ~]# lvs
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv01Fvg01     vg01 -wi-ao--- 500.00m
  lv02Fvg01     vg01 -wi-ao--- 300.00m
  testlv01Fvg02 vg02 -wi-ao--- 300.00m
  testlv02Fvg02 vg02 -wi-ao--- 400.00m

We also know that which VG has which PV.

For more details we can use,

LOGICAL VOLUME INFO (LV):

[root@rhel6-client1 ~]# lvs -o+lv_size
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert LSize
  lv01Fvg01     vg01 -wi-ao--- 500.00m                                              500.00m
  lv02Fvg01     vg01 -wi-ao--- 300.00m                                              300.00m
  testlv01Fvg02 vg02 -wi-ao--- 300.00m                                              300.00m
  testlv02Fvg02 vg02 -wi-ao--- 400.00m                                              400.00m

[root@rhel6-client1 ~]# lvs -o+lv_name
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert LV
  lv01Fvg01     vg01 -wi-ao--- 500.00m                                              lv01Fvg01
  lv02Fvg01     vg01 -wi-ao--- 300.00m                                              lv02Fvg01
  testlv01Fvg02 vg02 -wi-ao--- 300.00m                                              testlv01Fvg02
  testlv02Fvg02 vg02 -wi-ao--- 400.00m                                              testlv02Fvg02

[root@rhel6-client1 ~]# lvs -o+devices
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert Devices
  lv01Fvg01     vg01 -wi-ao--- 500.00m                                              /dev/sdd1(0)
  lv02Fvg01     vg01 -wi-ao--- 300.00m                                              /dev/sdd1(125)
  testlv01Fvg02 vg02 -wi-ao--- 300.00m                                              /dev/sdd3(0)
  testlv02Fvg02 vg02 -wi-ao--- 400.00m                                              /dev/sdd3(75)


VOLUME GROUP INFO (VG):

[root@rhel6-client1 ~]# vgs -o+vg_size
  VG   #PV #LV #SN Attr   VSize VFree VSize
  vg01   2   2   0 wz--n- 2.99g 2.21g 2.99g
  vg02   2   2   0 wz--n- 3.99g 3.31g 3.99g

[root@rhel6-client1 ~]# vgs -o+vg_name
  VG   #PV #LV #SN Attr   VSize VFree VG
  vg01   2   2   0 wz--n- 2.99g 2.21g vg01
  vg02   2   2   0 wz--n- 3.99g 3.31g vg02

[root@rhel6-client1 ~]# vgs -o+devices
  VG   #PV #LV #SN Attr   VSize VFree Devices
  vg01   2   2   0 wz--n- 2.99g 2.21g /dev/sdd1(0)
  vg01   2   2   0 wz--n- 2.99g 2.21g /dev/sdd1(125)
  vg02   2   2   0 wz--n- 3.99g 3.31g /dev/sdd3(0)
  vg02   2   2   0 wz--n- 3.99g 3.31g /dev/sdd3(75)

[root@rhel6-client1 ~]# vgs -o+lv_name
  VG   #PV #LV #SN Attr   VSize VFree LV
  vg01   2   2   0 wz--n- 2.99g 2.21g lv01Fvg01
  vg01   2   2   0 wz--n- 2.99g 2.21g lv02Fvg01
  vg02   2   2   0 wz--n- 3.99g 3.31g testlv01Fvg02
  vg02   2   2   0 wz--n- 3.99g 3.31g testlv02Fvg02

[root@rhel6-client1 ~]# vgs -o+pv_name
  VG   #PV #LV #SN Attr   VSize VFree PV
  vg01   2   2   0 wz--n- 2.99g 2.21g /dev/sdd1
  vg01   2   2   0 wz--n- 2.99g 2.21g /dev/sdd2
  vg02   2   2   0 wz--n- 3.99g 3.31g /dev/sdd3
  vg02   2   2   0 wz--n- 3.99g 3.31g /dev/sdd5

PHYSICAL VOLUME INFO (PV):

[root@rhel6-client1 ~]# pvs -o+devices
  PV         VG   Fmt  Attr PSize    PFree    Devices
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g /dev/sdd1(0)
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g /dev/sdd1(125)
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g /dev/sdd3(0)
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g /dev/sdd3(75)
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g

[root@rhel6-client1 ~]# pvs -o+pv_name
  PV         VG   Fmt  Attr PSize    PFree    PV
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g /dev/sdd1
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m /dev/sdd2
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g /dev/sdd3
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g /dev/sdd5

[root@rhel6-client1 ~]# pvs -o+pv_used
  PV         VG   Fmt  Attr PSize    PFree    Used
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g 800.00m
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m      0
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g 700.00m
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g      0

[root@rhel6-client1 ~]# pvs -o+pv_free
  PV         VG   Fmt  Attr PSize    PFree    PFree
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g    1.21g
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m 1020.00m
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g    1.31g
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g    2.00g

[root@rhel6-client1 ~]# pvs -o+vg_free
  PV         VG   Fmt  Attr PSize    PFree    VFree
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g 2.21g
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m 2.21g
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g 3.31g
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g 3.31g

[root@rhel6-client1 ~]# pvs -o+vg_name
  PV         VG   Fmt  Attr PSize    PFree    VG
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g vg01
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m vg01
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g vg02
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g vg02

 [root@rhel6-client1 ~]# pvs -o+vg_size
  PV         VG   Fmt  Attr PSize    PFree    VSize
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g 2.99g
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m 2.99g
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g 3.99g
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g 3.99g

[root@rhel6-client1 ~]# pvs -o+dev_size
  PV         VG   Fmt  Attr PSize    PFree    DevSize
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g   2.00g
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m   1.00g
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g   2.00g
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g   2.00g


I think now we have all the required info to remove unused disk.

From above command o/p we can identify that which disk has vg01 & vg02 are residing.

Again for ref,

[root@rhel6-client1 ~]# pvs -o+dev_size
  PV         VG   Fmt  Attr PSize    PFree    DevSize
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g   2.00g
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m   1.00g
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g   2.00g
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g   2.00g

[root@rhel6-client1 ~]# lvs -o+devices
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert Devices
  lv01Fvg01     vg01 -wi-ao--- 500.00m                                              /dev/sdd1(0)
  lv02Fvg01     vg01 -wi-ao--- 300.00m                                              /dev/sdd1(125)
  testlv01Fvg02 vg02 -wi-ao--- 300.00m                                              /dev/sdd3(0)
  testlv02Fvg02 vg02 -wi-ao--- 400.00m                                              /dev/sdd3(75)

[root@rhel6-client1 ~]# pvs -o+vg_size
  PV         VG   Fmt  Attr PSize    PFree    VSize
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g 2.99g
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m 2.99g
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g 3.99g
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g 3.99g

From all o/p’s we can see that
vg01 is only at /dev/sdd1
vg02 is only at /dev/sdd3 

Now we have 2 questions.
Can we move the data of “vg01” from /dev/sdd1 to /dev/sdd2 and remove /dev/sdd1.
Can we move the data of “vg02” from /dev/sdd3 to /dev/sdd5 and remove /dev/sdd3.

Let’s see what we can do to resolve such issue.

[root@rhel6-client1 ~]# pvs
  PV         VG   Fmt  Attr PSize    PFree
  /dev/sdd1  vg01 lvm2 a--     2.00g    1.21g
  /dev/sdd2  vg01 lvm2 a--  1020.00m 1020.00m
  /dev/sdd3  vg02 lvm2 a--     2.00g    1.31g
  /dev/sdd5  vg02 lvm2 a--     2.00g    2.00g

[root@rhel6-client1 ~]# pvmove /dev/sdd1
  /dev/sdd1: Moved: 1.5%
  /dev/sdd1: Moved: 62.5%
  /dev/sdd1: Moved: 100.0%

[root@rhel6-client1 ~]# pvmove /dev/sdd3
  /dev/sdd3: Moved: 1.7%
  /dev/sdd3: Moved: 42.9%
  /dev/sdd3: Moved: 100.0%

We have more possibilities with above command. What we can do is
First add a disk with larger size, realize it under same VG. Then do the

#pvmove OLD_DISK NEW_DISK

[root@rhel6-client1 ~]# pvs
  PV         VG   Fmt  Attr PSize    PFree
  /dev/sdd1  vg01 lvm2 a--     2.00g   2.00g
  /dev/sdd2  vg01 lvm2 a--  1020.00m 220.00m
  /dev/sdd3  vg02 lvm2 a--     2.00g   2.00g
  /dev/sdd5  vg02 lvm2 a--     2.00g   1.31g

Great……

Data moved to sdd2 & sdd5.

Now we can remove the sdd1 & sdd3.

[root@rhel6-client1 ~]# df -kh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda6              15G  6.3G  7.4G  46% /
tmpfs                 937M   76K  937M   1% /dev/shm
/dev/sda1             485M   37M  423M   8% /boot
/dev/sda3            1008M   34M  924M   4% /home
/dev/sda2             2.9G   69M  2.7G   3% /opt
/dev/mapper/vg02-testlv01Fvg02
                      291M   11M  266M   4% /testlv01Fvg02
/dev/mapper/vg02-testlv02Fvg02
                      388M   11M  358M   3% /testlv02Fvg02
/dev/mapper/vg01-lv01Fvg01
                      485M   11M  449M   3% /lv01Fvg01
/dev/mapper/vg01-lv02Fvg01
                      291M   11M  266M   4% /lv02Fvg01

[root@rhel6-client1 ~]# vgreduce vg01 /dev/sdd1
  Removed "/dev/sdd1" from volume group "vg01"
[root@rhel6-client1 ~]# vgreduce vg02 /dev/sdd3
  Removed "/dev/sdd3" from volume group "vg02"

[root@rhel6-client1 ~]# vgs -o+devices
  VG   #PV #LV #SN Attr   VSize    VFree   Devices
  vg01   1   2   0 wz--n- 1020.00m 220.00m /dev/sdd2(0)
  vg01   1   2   0 wz--n- 1020.00m 220.00m /dev/sdd2(125)
  vg02   1   2   0 wz--n-    2.00g   1.31g /dev/sdd5(0)
  vg02   1   2   0 wz--n-    2.00g   1.31g /dev/sdd5(75)

[root@rhel6-client1 ~]# df -kh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda6              15G  6.3G  7.4G  46% /
tmpfs                 937M   76K  937M   1% /dev/shm
/dev/sda1             485M   37M  423M   8% /boot
/dev/sda3            1008M   34M  924M   4% /home
/dev/sda2             2.9G   69M  2.7G   3% /opt
/dev/mapper/vg02-testlv01Fvg02
                      291M   11M  266M   4% /testlv01Fvg02
/dev/mapper/vg02-testlv02Fvg02
                      388M   11M  358M   3% /testlv02Fvg02
/dev/mapper/vg01-lv01Fvg01
                      485M   11M  449M   3% /lv01Fvg01
/dev/mapper/vg01-lv02Fvg01
                      291M   11M  266M   4% /lv02Fvg01

Well, now the sdd1 & sdd3 are removed from VG but still they are PV. If we want to use them external to LVM then we need to remove from LVM.

Need to confirm once again before removal…?

Though it is not necessary but there is no harm as well.

[root@rhel6-client1 ~]# pvs -o+pv_used
  PV         VG   Fmt  Attr PSize    PFree   Used
  /dev/sdd1       lvm2 a--     2.00g   2.00g      0
  /dev/sdd2  vg01 lvm2 a--  1020.00m 220.00m 800.00m
  /dev/sdd3       lvm2 a--     2.00g   2.00g      0
  /dev/sdd5  vg02 lvm2 a--     2.00g   1.31g 700.00m

Great,

[root@rhel6-client1 ~]# pvremove /dev/sdd1 /dev/sdd3
  Labels on physical volume "/dev/sdd1" successfully wiped
  Labels on physical volume "/dev/sdd3" successfully wiped

[root@rhel6-client1 ~]# pvs -o+pv_used
  PV         VG   Fmt  Attr PSize    PFree   Used
  /dev/sdd2  vg01 lvm2 a--  1020.00m 220.00m 800.00m
  /dev/sdd5  vg02 lvm2 a--     2.00g   1.31g 700.00m

To get various options,

[root@rhel6-client1 ~]# lvs -o+
[root@rhel6-client1 ~]# pvs -o+
[root@rhel6-client1 ~]# vgs -o+

  Logical Volume Fields
  ---------------------
    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.
    lv_metadata_size     - For thin pools, the size of the LV that holds the metadata.
    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.
    data_percent         - For snapshot and thin pools and volumes, the percentage full if LV is active.
    snap_percent         - For snapshots, the percentage full if LV is active.
    metadata_percent     - For thin pools, the percentage of metadata full if LV is active.
    copy_percent         - For RAID, mirrors and pvmove, current percentage in-sync.
    sync_percent         - For RAID, 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.
    mirror_log           - For mirrors, the LV holding the synchronisation log.
    data_lv              - For thin pools, the LV holding the associated data.
    metadata_lv          - For thin pools, the LV holding the associated metadata.
    pool_lv              - For thin volumes, the thin pool LV for this volume.
    lv_tags              - Tags, if any.
    lv_time              - Creation time of the LV, if known
    lv_host              - Creation host of the LV, if known.
    modules              - Kernel device-mapper modules required for this LV.

  Physical Volume Label Fields
  ----------------------------
    pv_all               - All fields in this section.
    pv_fmt               - Type of metadata.
    pv_uuid              - Unique identifier.
    dev_size             - Size of underlying device in current units.
    pv_name              - Name.
    pv_mda_free          - Free metadata area space on this device in current units.
    pv_mda_size          - Size of smallest metadata area on this device in current units.

  Physical Volume Fields
  ----------------------
    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.

  Volume Group Fields
  -------------------
    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.

  Logical Volume Segment Fields
  -----------------------------
    seg_all              - All fields in this section.
    segtype              - Type of LV segment.
    stripes              - Number of stripes or mirror legs.
    stripesize           - For stripes, amount of data placed on one device before switching to the next.
    stripe_size          - For stripes, amount of data placed on one device before switching to the next.
    regionsize           - For mirrors, the unit of data copied when synchronising devices.
    region_size          - For mirrors, the unit of data copied when synchronising devices.
    chunksize            - For snapshots, the unit of data used when tracking changes.
    chunk_size           - For snapshots, the unit of data used when tracking changes.
    thin_count           - For thin pools, the number of thin volumes in this pool.
    discards             - For thin pools, how discards are handled.
    zero                 - For thin pools, if zeroing is enabled.
    transaction_id       - For thin pools, the transaction id.
    seg_start            - Offset within the LV to the start of the segment in current units.
    seg_start_pe         - Offset within the LV to the start of the segment in physical extents.
    seg_size             - Size of segment in current units.
    seg_tags             - Tags, if any.
    seg_pe_ranges        - Ranges of Physical Extents of underlying devices in command line format.
    devices              - Underlying devices used with starting extent numbers.

  Physical Volume Segment Fields
  ------------------------------
    pvseg_all            - All fields in this section.
    pvseg_start          - Physical Extent number of start of segment.
    pvseg_size           - Number of extents in segment.

  Unrecognised field:



















No comments:

Post a Comment