• 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. K3b Nero like CD/DVD Burning Software in Ubuntu Linux
  2. How to Update the hostname in Shell Prompt Once it is Changed in the Linux OS
  3. yum-config-manager: command not found
  4. How to Debug systemd boot process in CentOS/RHEL 7 and 8
  5. Honeypot Tutorials – Modes and Working of Honeypot
  6. How to remove the multipath device after unmapping the storage LUN from server
  7. LVM ISCSI Physical Volume Not Available After Server Reboot
  8. How to Add Network Printer via Command Line in CentOS/RHEL
  9. CentOS / RHEL : Converting an Existing Root Filesystem to LVM Partition
  10. How to Limit/throttle rsync transfer speed in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright