• 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

lvremove Command Examples in Linux

by admin

Deleting a volume frees its storage back to the volume group, which can then be used to create new logical volumes or support growing an existing volume. lvremove command can be used to delete an LVM volume which we no longer intend to use. Please make sure you take a backup of the mount point in case you may want the data in it later on.

How to remove a LVM volume with lvremove

1. Unmount the filesystem with umount:

# umount /mnt

2. Open /etc/fstab and verify that there isn’t an entry to automatically mount the filesystem. If there is, remove the entry, save your changes, and close the file.

3. Use lvremove to delete the logical volume:

# lvremove vg0/myvol

4. Review the output of lvs to verify the removal.

# lvs

How to remove LVM volume with error “filesystem in use”

Sometimes you might get below error while removing an LVM volume:

# lvchange -an /dev/mapper/vg-lv
Logical volume vg/lv contains a filesystem in use

You may follow the steps outlined below in such cases:

Step 1: Try to identify if this particular LVM is mounted in your server.

# mount -a |grep /path-to-LV-volume

If mounted, unmount it.

Step 2: Check for open file desriptors or active processes running on this LV.

# lsof | grep /path-to-LV-volume

If the above command doesn’t return any output, try to ‘grep’ using just LV name. If you see any open processes or file descriptors, kill them using ‘pkill’ or ‘kill -9’ [ ‘man’ command for options].

Step 3: Remove LV.

# lvchange -an -v /path-to-LV-volume
# lvremove -vf /path-to-LV-volume

Replace /path-to-LV-volume with actual path in the above commands.

lvremove Command Examples

1. To remove the logical volume:

# lvremove LV00

2. To forcefully remove the logical volume:

# lvremove -f LV00
# lvremove --force LV00

3. To disable udev synchronization:

# lvremove --noudevsync

4. To remove all logical volumes under any VG:

# lvremove VG00

Filed Under: Linux

Some more articles you might also be interested in …

  1. Audit Rule Configuration not Reflected – How to troubleshoot
  2. Apache HTTP server – most commonly used containers (special configuration directives)
  3. “mdadm: No arrays found in config file” – error on running ‘mdadm –assemble –scan’
  4. How to Setup a squid proxy server on CentOS/RHEL 7
  5. Anonymous User Fails to Upload File to VSFTP Server
  6. Sample /etc/services file in Linux
  7. CentOS / RHEL 6 : How to list or install only security updates with yum
  8. CentOS / RHEL : How to determine which SNMP version is being used
  9. How to Limit/throttle rsync transfer speed in Linux
  10. Windows Active Directory Account Shows Inconsistent UID/GID In Different Linux SSSD Clients (CentOS/RHEL)

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright