This article was sponsored by Xiuyi linfeng and first launched in the dark world.
In the previous article, we introduced the logical volume of LVM and the reduction of the volume group space. This time we will introduce how to delete a logical volume and a volume group.
To delete a logical volume, follow these steps:
1. Detach a mounted logical volume
2. Delete the logical volume and run the lvremove command.
First, you can view the mount information of the logical volume as follows:
DF-H
Detach a mounted logical volume as follows:
Umount/testlvm/
Now let's view the information about the logical volume. Use the LVS or lvdisplay Command, as shown below:
We can see that there is only one logical volume/dev/vg1/data in the LVM, And the size is 300 MB.
Now the lvremove command is available to delete the logical volume/dev/vg1/data. As follows:
Lvremove/dev/vg1/Data
For how to use the lvremove command, see the help below:
Lvremove -- Help
The preceding operations are related to deleting logical volumes. Next we will delete the volume group. Deleting a volume group is simple. You only need to use the vgremove command.
Before deleting a logical volume, we can view its related information. As follows:
We can see two physical volumes/dev/sda5/AND/dev/sda6 in the system, in addition, the physical volume/dev/sda5/has been added to the volume group vg1.
Now we can use the vgremove command to delete the volume group vg1. As follows:
Vgremove vg1
After the volume group is deleted, let's check the information about the physical volume. As follows:
We can see that the two physical volumes in the system do not belong to any volume group.
For more information about how to use the vgremove command, see the help documentation. As follows:
So far, the deletion of our volume group has been completed.
Next we will delete the physical volume, which can be achieved through the pvremove command.
Pvremove/dev/sda5
We can see that the physical volume/dev/sda5 has been deleted. If/dev/sda5 is a hard disk, we can easily remove it now.
For the usage of the pvremove command, you can view the help documentation. As follows:
This section describes how to delete logical volumes, Volume groups, and physical volumes.