Removing a disk from a volume group - denis-kol4ev/OraDBA GitHub Wiki
Based on RedHat documentation
Tested on Oracle Linux Server release 7.6
Note: Operations in this guide were completed online, with mounted filesystem and running oracle rdbms on it.
This example shows how you can replace two 20G disks in vg_soft with one 40G disk. In order to remove a disk, you must first move the extents on the LVM physical volume to a different disk or set of disks.
1. Initial state
[root@angel ~]# pvs -o+pv_used --units h
PV VG Fmt Attr PSize PFree Used
/dev/sda2 vg_root lvm2 a-- 19.00g 0 19.00g
/dev/sdb vg_soft lvm2 a-- 20.00g 0 20.00g
/dev/sdc vg_soft lvm2 a-- 20.00g 0 20.00g
/dev/sdd vg_data lvm2 a-- 20.00g 0 20.00g
2. Creating the new physical volume
[root@angel ~]# pvcreate /dev/sdi
Physical volume "/dev/sdi" successfully created.
3. Adding the new physical volume to the volume Group
[root@angel ~]# vgextend vg_soft /dev/sdi
Volume group "vg_soft" successfully extended
[root@angel ~]# pvs -o+pv_used --units h
PV VG Fmt Attr PSize PFree Used
/dev/sda2 vg_root lvm2 a-- 19.00g 0 19.00g
/dev/sdb vg_soft lvm2 a-- 20.00g 0 20.00g
/dev/sdc vg_soft lvm2 a-- 20.00g 0 20.00g
/dev/sdd vg_data lvm2 a-- 20.00g 0 20.00g
/dev/sdi vg_soft lvm2 a-- 40.00g 40.00g 0
4. Moving the data
Use the pvmove command to move the data from /dev/sdb and /dev/sdc to /dev/sdi
[root@angel ~]# pvmove /dev/sdb /dev/sdi
/dev/sdb: Moved: 0.18%
...
/dev/sdb: Moved: 50.17%
...
/dev/sdb: Moved: 100.00%
[root@angel ~]# pvmove /dev/sdc /dev/sdi
/dev/sdc: Moved: 0.04%
...
/dev/sdc: Moved: 57.10%
...
/dev/sdc: Moved: 100.00%
After the pvmove command has finished executing, the distribution of extents is as follows:
[root@angel ~]# pvs -o+pv_used --units h
PV VG Fmt Attr PSize PFree Used
/dev/sda2 vg_root lvm2 a-- 19.00g 0 19.00g
/dev/sdb vg_soft lvm2 a-- 20.00g 20.00g 0
/dev/sdc vg_soft lvm2 a-- 20.00g 20.00g 0
/dev/sdd vg_data lvm2 a-- 20.00g 0 20.00g
/dev/sdi vg_soft lvm2 a-- 40.00g 4.00m 39.99g
5. Use the vgreduce command to remove the physical volumes sdb and sdc from the volume group
[root@angel ~]# vgreduce vg_soft /dev/sdb /dev/sdc
Removed "/dev/sdb" from volume group "vg_soft"
Removed "/dev/sdc" from volume group "vg_soft"
[root@angel ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_root lvm2 a-- <19.00g 0
/dev/sdb lvm2 --- 20.00g 20.00g
/dev/sdc lvm2 --- 20.00g 20.00g
/dev/sdd vg_data lvm2 a-- <20.00g 0
/dev/sdi vg_soft lvm2 a-- <40.00g 4.00m
You can now reallocate the disk to another volume group or remove the disk from the system.