Forcibly remove a stuck dm mapping

From HeepyWiki
Jump to navigation Jump to search

This happens sometimes when you use something like kpartx to generate mappings for a lvm volume, so you can mount its partitions. Once you unmount, kpartx -d is supposed to remove all those mappings so that the lvm volume is free to be removed, but sometimes they get stuck, for instances when a snapshot or copy-on-write volume exists. You can forcibly remove the device mapper entry but it's probably dangerous, at least if you want to keep the volume. But usually you're trying to do this in order to be able to remove the volume, so whatever.

dmsetup -v remove --force /dev/mapper/vg00-debsnap1
lvremove /dev/vg00/debsnap