lvremove failed with error " Logical volume vgname/lvname contains a filesystem in use."

Environment

  • Red Hat Enterprise Linux 6

Issue

  • Not able to remove unounted logical volume.
  • lvremove failed with below error.
# lvremove /dev/mapper/testvg-testlv
  Logical volume testvg-testlv contains a filesystem in use.

Resolution

  • Stop nfs service and remove logical volume.
  • Check whether there are any processes which are accessing the logical volume. In some cases kernel thread for journald might be accessing the LVM device due to which the lvm can be left open. In such case rebooting the server is the safest way to recover since the journald process should not be killed.

Root Cause

  • Mount point was exported through nfs.

Diagnostic Steps

1. Verify filesystem is not mounted.
# df 
# cat /proc/mount
2. verify no process in lsof/fuser is holdering this lv or mount point.
3. Verify whether this lv is exported through nfs
#cat /etc/exportfs
4. Try to to flush block device and drop cache
# blockdev --flushbufs /dev/vg/lv
# echo 1 > /proc/sys/vm/drop_caches
# echo 2 > /proc/sys/vm/drop_caches
# echo 3 > /proc/sys/vm/drop_caches

No comments: