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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. Xen Hypervisor (xm) command Cheat Sheet
  2. Configuring Remote Logging using rsyslog in CentOS/RHEL
  3. Spacewalk Installation Steps On CentOS/RHEL
  4. mkfs.ext4 Command Examples in Linux
  5. pvscan Command Examples in Linux
  6. Understanding System Security Services Daemon (SSSD)
  7. How to Audit File Access on Linux
  8. How to change the default location (/var/cache/yum) of yum cache
  9. 11 Useful “ssh” and “scp” Commands in Linux
  10. How to Install NTP Service and Client in CentOS/RHEL 8

You May Also Like

Primary Sidebar

Recent Posts

  • What are /dev/zero and /dev/null files in Linux
  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright