Tuesday, 25 March 2014

Unable to remove LVM snapshots, LVM gets suspended

What:

SLES 11-SP3 or any other linux with LVM

Problem:

When using lvremove to remove snapshot, LVM hungs with the following error:

Unable to deactivate open snap01-cow (253:3)
Failed to resume snap01.
libdevmapper exiting with 1 device(s) still suspended.

If you have vm's on your lvm volume, they get suspended and it seems that the only solution is to forcefully restart your server.

Solution:

First, there is a way to recover your system without a restart.
Second, workaround exists to prevent it.

How to recover from suspended LVM
------------------------------------------------------------

Check lvm state with:
dmsetup info
You should see a suspended device, quick fix instead of rebooting the server is to resume device, then you should be able to remove snapshot.
dmsetup resume /dev/<vgroup>/<volume>
<vgroup> - volume group
lvremove -f /dev/<vgroup>/snap01
If lvremove fails, then you need to do a manual clean up. Check the following locations for leftovers:
ls -l /dev/mapper
ls -l /dev/<vgroup>

To remove /dev/mapper/<vgroup>-<volume>-real use the following trick:
lvcreate -s -n temp -L 1G /dev/<vgroup>/<volume>
lvremove -f /dev/<vgroup>/temp

Workaround
--------------------

Trick is to use a "dmsetup remove" to deactivate the snapshot first.
dmsetup -f remove /dev/mapper/<vgroup>-snap01
dmsetup -f remove /dev/mapper/<vgroup>-snap01-cow
lvremove -f /dev/<vgroup>/snap01

No comments:

Post a Comment