Removing Logical Volumes, Physical Volumes, and Volume Groups

Start course
Overview
Difficulty
Intermediate
Duration
40m
Students
3
Description

The Logical Volume Manager introduces extra layers of abstraction between the disks or storage devices presented to a Linux system and the file systems placed on them. This course explores the service and its components. This course is part of the Linux Administration Bootcamp learning path, designed to get you up and running with Linux.

Learning Objectives

  • Understand what the LVM is and how it works
  • Create and remove physical volumes (PVs), volume groups (VGs), and logical volumes (LVs)
  • Extend volume groups and extend and mirror logical volumes
  • Migrate Data from one storage device to another

Intended Audience

  • Anyone with basic knowledge of Linux who wants to learn more
  • Professionals who want to learn more about Linux to enhance their career prospects

Prerequisites

This is an intermediate-level course so some knowledge of Linux is expected. If you're just starting out, then try our Linux Fundamentals course first.

Transcript

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
Avatar
Jason Cannon
Founder, Linux Training Academy
Students
304
Courses
40
Learning Paths
4

Jason is the founder of the Linux Training Academy as well as the author of "Linux for Beginners" and "Command Line Kung Fu." He has over 20 years of professional Linux experience, having worked for industry leaders such as Hewlett-Packard, Xerox, UPS, FireEye, and Amazon.com. Nothing gives him more satisfaction than knowing he has helped thousands of IT professionals level up their careers through his many books and courses.

Covered Topics