4.5. Removing a disk from a logical volume
This procedure describes how to remove a disk from an existing logical volume, either to replace the disk or to use the disk as part of a different volume.
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.
Procédure
View the used and free space of physical volumes when using the LV:
pvs -o+pv_used
# pvs -o+pv_used 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 myvg lvm2 a-- 1020.00m 1008.00m 12.00mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Move the data to other physical volume:
If there are enough free extents on the other physical volumes in the existing volume group, use the following command to move the data:
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, use the following commands to add a new physical volume, extend the volume group using the newly created physical volume, and move the data to this physical volume:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Remove the physical volume:
vgreduce myvg /dev/vdb3
# vgreduce myvg /dev/vdb3 Removed "/dev/vdb3" from volume group "myvg"Copy to Clipboard Copied! Toggle word wrap Toggle overflow If a logical volume contains a physical volume that fails, you cannot use that logical volume. To remove missing physical volumes from a volume group, you can use the
--removemissingparameter of thevgreducecommand, if there are no logical volumes that are allocated on the missing physical volumes:vgreduce --removemissing myvg
# vgreduce --removemissing myvgCopy to Clipboard Copied! Toggle word wrap Toggle overflow