3.3. Removing physical volumes from a volume group
To remove unused physical volumes from a volume group, use the vgreduce command. The vgreduce command shrinks a volume group’s capacity by removing one or more empty physical volumes. This frees those physical volumes to be used in different volume groups or to be removed from the system.
Procédure
If the physical volume is still being used, migrate the data to another physical volume from the same volume group :
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If there are no enough free extents on the other physical volumes in the existing volume group:
Create a new physical volume from /dev/vdb4:
pvcreate /dev/vdb4
# pvcreate /dev/vdb4 Physical volume "/dev/vdb4" successfully createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the newly created physical volume to the myvg volume group:
vgextend myvg /dev/vdb4
# vgextend myvg /dev/vdb4 Volume group "myvg" successfully extendedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Move the data from /dev/vdb3 to /dev/vdb4:
pvmove /dev/vdb3 /dev/vdb4
# pvmove /dev/vdb3 /dev/vdb4 /dev/vdb3: Moved: 33.33% /dev/vdb3: Moved: 100.00%Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Remove the physical volume /dev/vdb3 from the volume group:
vgreduce myvg /dev/vdb3
# vgreduce myvg /dev/vdb3 Removed "/dev/vdb3" from volume group "myvg"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Vérification
Verify if the /dev/vdb3 physical volume is removed from the myvg volume group:
pvs
# pvs PV VG Fmt Attr PSize PFree Used /dev/vdb1 myvg lvm2 a-- 1020.00m 0 1020.00m /dev/vdb2 myvg lvm2 a-- 1020.00m 0 1020.00m /dev/vdb3 lvm2 a-- 1020.00m 1008.00m 12.00mCopy to Clipboard Copied! Toggle word wrap Toggle overflow