Removing Logical Volumes, Physical Volumes, and Volume Groups
Start course
7h 28m

In this course, you will learn how to install a Linux system and connect to it, whether that be on Mac or Windows.


Before we wrap up this lesson, I wanna show you how to undo your changes, or how to delete logical volumes of volume groups and physical volumes. First, let's start out by unmounting the file system that we just mounted. So we'll unmount secrets here, and now we can remove the underlying logical volume. They asked us, "Do you really want to remove "and discard all this data that resides here?" And we're gonna say "Y" for yes. So by the way, once you do that, your data that was on that file system, or on that logical volume, is gone. If you want to remove a PV from a VG, use the vgreduce command.

Now first, let's show that we have two PVs and VG. So in the PV column we have two for our vg_safe volume group. So let's do this vgreduce, the name of the volume group, and let's give it dev/sde. Now, if we look at it, we only have one physical volume and vg_safe. Now that PV that we just removed, is free to be used in another volume group if we wanted to. Or if you don't wanna use that disk with LVM, you can free it up or remove it from the Logical Volume Manager with the pvremove command, and let's do that here now.

So now, if we look at our PVs, we do not see dev/sde anywhere in our list. Let's finish destroying the vg_safe volume group with the vgremove command. So if we run our VGs command, vg_safe is not there anymore because we just removed it. And if we run our PVs command, we can see that that one final disc that was in that volume group, is now freed up to be used by another volume group. There's no volume group in the VG column beside dev/sdd. Now, if we're done with that disc, we can pvremove it, like we did the other one. So we can do pvremove /dev/sdd, run PVs, and then, of course, that is not listed in LVM.

About the Author
Learning Paths

A world-leading tech and digital skills organization, we help many of the world’s leading companies to build their tech and digital capabilities via our range of world-class training courses, reskilling bootcamps, work-based learning programs, and apprenticeships. We also create bespoke solutions, blending elements to meet specific client needs.