Removing physical volume from VG
Step 1: Move Data Off the Physical Volume with pvmove
pvmove
Before removing the physical volume, you need to ensure that all data on the physical volume is moved to other available physical volumes in the volume group.
Move data off
/dev/sdb1
:Run the
pvmove
command to move data off the physical volume/dev/sdb1
(or whatever physical volume you want to remove):This will move the data to other physical volumes in the volume group. You should wait for this process to complete before proceeding. You can check the progress with the following command:
When
pvmove
finishes, all the data will be relocated, and/dev/sdb1
will be free.
Step 2: Remove the Physical Volume from the Volume Group
Once the data has been moved, you can attempt to remove /dev/sdb1
from the volume group.
Try to remove the physical volume:
Use the
vgreduce
command to remove/dev/sdb1
from the volume group:Replace
myvg
with the name of your volume group.Note: If there are no allocation extents left on
/dev/sdb1
, the command may fail with an error such as:
Step 3: Add a New Disk (If Needed)
If the vgreduce
command fails with the error "No allocation extents available," it means the volume group is full, and there is no free space available to remove the physical volume. In this case, you need to extend the volume group by adding a new disk.
Add a new disk to the volume group:
If you have a new disk (e.g.,
/dev/sdc
) that you can add to the volume group, first partition it usingfdisk
orparted
to create an LVM partition (8e
type). Afterward, use the following command to add the new disk to the volume group:This adds the new disk (
/dev/sdc
) to the volume group, freeing up space for thevgreduce
operation.
Step 4: Retry Removing the Physical Volume
Once you have added a new disk to the volume group and extended the group, you should now have enough space to remove the physical volume.
Remove the physical volume:
Run the
vgreduce
command again to remove/dev/sdb1
:If successful,
/dev/sdb1
will be removed from the volume group.
Step 5: Remove the Physical Volume Label
Once the physical volume is no longer part of the volume group, you can remove the LVM metadata and label from the disk, which makes it available for reuse.
Remove the LVM metadata from
/dev/sdb1
:This will completely erase the LVM metadata from
/dev/sdb1
and make it ready for other uses, such as creating a new partition or using it for a different purpose.
Step 6: Verify the Changes
Check the volume group to confirm the removal:
This will show the updated details of the volume group.
/dev/sdb1
should no longer be listed as part of the group.Check the physical volume list:
This will show the physical volumes in use by the volume group.
/dev/sdb1
should no longer appear.
Last updated