Environment:
## Disk devices information.
[root@CentOS ~]# fdisk -l | grep "Disk /dev/sd"
----------------------------------------------------------
Disk /dev/sdb: 3999.7 GB, 3999688294400 bytes
Disk /dev/sdc: 3000.0 GB, 3000034656256 bytes
Disk /dev/sda: 1999.8 GB, 1999844147200 bytes
----------------------------------------------------------
## Only the /dev/sdb is PV.
[root@CentOS ~]# pvscan
----------------------------------------------------------
PV /dev/sdb VG vg001 lvm2 [3.64 TiB / 693.88 GiB free]
Total: 1 [3.64 TiB] / in use: 1 [3.64 TiB] / in no VG: 0 [0 ]
----------------------------------------------------------
## OS has a VG (vg001) currently.
[root@CentOS ~]# vgscan
----------------------------------------------------------
Reading all physical volumes. This may take a while...
Found volume group "vg001" using metadata type lvm2
----------------------------------------------------------
Add /dev/sdc in VG (vg001):
## Check VG size.
[root@CentOS ~]# vgdisplay
----------------------------------------------------------
--- Volume group ---
VG Name vg001
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 238
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 47
Open LV 47
Max PV 0
Cur PV 1
Act PV 1
VG Size 3.64 TiB
PE Size 4.00 MiB
Total PE 953599
Alloc PE / Size 775965 / 2.96 TiB
Free PE / Size 177634 / 693.88 GiB
VG UUID lFb7MM-fXrz-6Zce-TOYK-pvIs-qPxo-2O2b7A
----------------------------------------------------------
## I am going to add a PV (/dev/sdc).
[root@CentOS ~]# pvcreate /dev/sdc
----------------------------------------------------------
Physical volume "/dev/sdc" successfully created
----------------------------------------------------------
## I am going to extend VG (vg001) size by a PV (/dev/sdc).
[root@CentOS ~]# vgextend vg001 /dev/sdc
----------------------------------------------------------
Volume group "vg001" successfully extended
----------------------------------------------------------
## VG (vg001) already included PV (/dev/sdc).
[root@CentOS ~]# pvscan
----------------------------------------------------------
PV /dev/sdb VG vg001 lvm2 [3.64 TiB / 693.88 GiB free]
PV /dev/sdc VG vg001 lvm2 [2.73 TiB / 2.73 TiB free]
Total: 2 [6.37 TiB] / in use: 2 [6.37 TiB] / in no VG: 0 [0 ]
----------------------------------------------------------
## Check VG size.
[root@CentOS ~]# vgdisplay
----------------------------------------------------------
--- Volume group ---
VG Name vg001
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 239
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 47
Open LV 47
Max PV 0
Cur PV 2
Act PV 2
VG Size 6.37 TiB
PE Size 4.00 MiB
Total PE 1668862
Alloc PE / Size 775965 / 2.96 TiB
Free PE / Size 892897 / 3.41 TiB
VG UUID lFb7MM-fXrz-6Zce-TOYK-pvIs-qPxo-2O2b7A
----------------------------------------------------------
Remove /dev/sdc in VG (vg001):
## Both /dev/sdb and /dev/sdc are PVs in VG (vg001).
[root@CentOS ~]# pvscan
----------------------------------------------------------
PV /dev/sdb VG vg001 lvm2 [3.64 TiB / 693.88 GiB free]
PV /dev/sdc VG vg001 lvm2 [2.73 TiB / 2.73 TiB free]
Total: 2 [6.37 TiB] / in use: 2 [6.37 TiB] / in no VG: 0 [0 ]
----------------------------------------------------------
## OS has a VG vg001 currently.
[root@CentOS ~]# vgscan
----------------------------------------------------------
Reading all physical volumes. This may take a while...
Found volume group "vg001" using metadata type lvm2
----------------------------------------------------------
## Remove /dev/sdc in VG (vg001).
[root@CentOS ~]# vgreduce vg001 /dev/sdc
----------------------------------------------------------
Removed "/dev/sdc" from volume group "vg001"
----------------------------------------------------------
## You can do this command below,
## if command "vgreduce" has failed or PV (/dev/sdc) has used.
[root@CentOS ~]# pvmove --abort
## Check VG size.
[root@CentOS ~]# vgdisplay
----------------------------------------------------------
--- Volume group ---
VG Name vg001
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 240
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 47
Open LV 47
Max PV 0
Cur PV 1
Act PV 1
VG Size 3.64 TiB
PE Size 4.00 MiB
Total PE 953599
Alloc PE / Size 775965 / 2.96 TiB
Free PE / Size 177634 / 693.88 GiB
VG UUID lFb7MM-fXrz-6Zce-TOYK-pvIs-qPxo-2O2b7A
----------------------------------------------------------
## Check PV (/dev/sdc) is already remove in VG (vg001).
[root@CentOS ~]# pvscan
----------------------------------------------------------
PV /dev/sdb VG vg001 lvm2 [3.64 TiB / 693.88 GiB free]
PV /dev/sdc lvm2 [2.73 TiB]
Total: 2 [6.37 TiB] / in use: 1 [3.64 TiB] / in no VG: 1 [2.73 TiB]
----------------------------------------------------------
## Remove /dev/sdc in PVs.
[root@CentOS ~]# pvremove /dev/sdc
----------------------------------------------------------
Labels on physical volume "/dev/sdc" successfully wiped
----------------------------------------------------------
## Check /dev/sdc is already remove completely in PVs.
[root@CentOS ~]# pvscan
----------------------------------------------------------
PV /dev/sdb VG vg001 lvm2 [3.64 TiB / 693.88 GiB free]
Total: 1 [3.64 TiB] / in use: 1 [3.64 TiB] / in no VG: 0 [0 ]
----------------------------------------------------------
留言列表