How to remove LVM snapshots if you get message "Can't remove open logical volume"

root's picture

Let's say you have created a snapshot, you have used it and now you want to remove it.
What you can do if you get the following message?

core:~# lvscan | grep mylv
  ACTIVE   Original '/dev/datavg/mylv' [2.00 GiB] inherit
  ACTIVE   Snapshot '/dev/datavg/snapmylv' [1.00 GiB] inherit
  
core:~# lvremove -f /dev/datavg/snapmylv
  [color=red]Can't remove open logical volume "snapmylv"[/color]

One way is to ask dmsetup for help:

core:~# [color=green]dmsetup -f remove /dev/mapper/datavg-snapmylv[/color]
core:~# [color=green]dmsetup -f remove /dev/mapper/datavg-snapmylv-cow[/color]
core:~# [color=green]lvremove -f /dev/datavg/snapmylv[/color]
  Logical volume "snapmylv" successfully removed

core:~# lvscan | grep mylv
  ACTIVE            '/dev/datavg/mylv' [2.00 GiB] inherit

If I will find other ways, I will write here.
DONE!

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content

root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root