• 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

How To Remove Disk from a LVM Volume Group

by admin

Any activities pertaining to shrinking of volumes and file system sizes is considered high risk. One main reason is that we cannot revert and fix the file system if it encounters an error. As a general rule of thumb, a good back out plan should be in place. Virtual machine has a snapshot features and this needs to be utilized prior to shrinking of volumes and filesystems. In the case of a physical server, make sure a completed backup of mount points is taken prior to performing the disk removal.

Before we remove any disks in a volume group, the following needs to be performed:

  • Determine the physical extents of the logical volumes and volume groups. We must ensure that there are no other physical extents assigned to a logical volume groups before proceeding to the change activity.
  • Regardless the file system format, whether it is EXT or XFS, if the device does not have physical extent bindings the device can be removed.
  • If the device for removal contains physical extent, it will need to be destroyed first before completely removing the disk from the volume group.
  • If the logical volume groups are not using the device’s physical extent, the device can be removed without unmounting the volume groups. vgreduce would register an error stating that the device is busy if there are logical volumes using it regardless of whether it is mounted or not.

Pre-Checks

1. Locate the affected Volume:

# lsblk

2. Determine Physical extents of Physical Volume, Volume Group, and Logical Volume:

# pvdisplay [PV name]
# vgdisplay -v [VG name] | egrep "Name|Alloc PE|PV Name|Total PE"
# lvdisplay -m [VG name]

3. Before unmounting the volume, make sure that there are no running processes on top of the logical volume:

# lsof [mount point]

Note: Running lsof must not return any output.

VG Reduce

Note: Backup the whole Volume Group either by the VM level snapshot or OS level LVM snapshot and make sure volumes can be restored from the snapshot.

1. If a Physical Volume has a Logical Volume bindings, therefore unmount the volume and destroy it is needed:

# umount [mount point] && lvchange -a n [LV path]

2. Remove the Logical Volume:

# lvremove [LV path]

3. Remove the Physical Volume from the Volume Group:

# vgreduce [volume group] [physical volume]
Note: Executing lvremove has to be executed prior to the removal of the disk.

Filed Under: CentOS/RHEL, Linux

Some more articles you might also be interested in …

  1. How To Create/Remove and Mount a Stratis Filesystem in CentOS/RHEL 8
  2. CentOS / RHEL 6 : How to setup yum repository using locally mounted DVD
  3. gpasswd: command not found
  4. Echo Command with Practical Examples
  5. dnsspoof: command not found
  6. How To Disable Weak Cipher And Insecure HMAC Algorithms in SSH services for CentOS/RHEL 6 and 7
  7. How To Increase The Retention Of “sar” Data To ‘N’ Days in Linux
  8. file: command not found
  9. insmod: command not found
  10. rm Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • qtchooser Command Examples in Linux
  • qtchooser: command not found
  • qsub Command Examples in Linux
  • qsub: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright