The Problem
How to remove an LVM volume which returns “filesystem in use” error.
# lvchange -an /dev/mapper/vg-lv Logical volume vg/lv contains a filesystem in use
The Solution
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 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: Deactivate and remove the LV.
# lvchange -an -v /path-to-LV-volume # lvremove -vf /path-to-LV-volume
Note: Replace /path-to-LV-volume with actual path in the above commands.