• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL : How to remove unused Physical Volume(PV) from Volume Group (VG) in LVM

by admin

To remove any physical volume in a volume group vgreduce command can be used. The vgreduce command shrinks the volume group by removing one or more PVs. We can then either use these free PVS in another VG or remove them from the LVM configuration.

Removing the PV

1. Before removing a physical volume from a volume group, you can make sure that the physical volume is not used by any logical volumes by using the pvdisplay command.

# pvdisplay /dev/sdb1 -m
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               vg_os2
  PV Size               558.88 GiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              143072
  Free PE               40672
  Allocated PE          102400
  PV UUID               EPwws6-yxK0-7Ycb-IbFC-iYzE-5vNk-eQ7mYl

  --- Physical Segments ---
  Physical extent 0 to 51199:
    Logical volume      /dev/vg_os2/lv_data
    Logical extents     0 to 51199

As shown in the commnad output above, the PV /dev/sdb1 is in use in the LV /dev/vg_os2/lv_data. If the physical volume you want to delete have some data, you can move it using the pvmove command and then delete the LV. refer the posts below to migrate the data and remove LV:

CentOS / RHEL : How to migrate storage (LVM) with pvmove Command
CentOS / RHEL : How to delete LVM volume

2. Use the vgreduce command to remove the physical volume. The following command removes the physical volume /dev/hda1 from the volume group my_volume_group.

# vgreduce vg_os2 /dev/sdb1
Search or use up and down arrow keys to select an item. CentOS / RHEL : How to remove used Physical Volume(PV) from Volume Group (VG) in LVM

Filed Under: Linux

Some more articles you might also be interested in …

  1. Using grep to search in reverse
  2. coffee: Executes CoffeeScript scripts or compiles them into JavaScript
  3. chgrp: command not found
  4. awslogs Command Examples (Queries groups, streams and events from Amazon CloudWatch logs)
  5. How to Reduce an LVM volume on Ubuntu
  6. Auditd Messages Are Filling Up /var/log/messages
  7. grub-bios-setup Command Examples in Linux
  8. rename Command Examples in Linux
  9. mke2fs Command Examples in Linux
  10. ndctl: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright