19 March 2013

Can't remove open logical volume "lv_name"

This was an interesting thing to find...
# lvremove /dev/vg00/lv_name
Can't remove open logical volume "lv_name"
So I checked if my LV is mounted... and it was.
# mount
...
/dev/mapper/vg00-lv_name on /mount_point type ext4 (rw,noatime,errors=remount-ro)
...
Standard unmounting didn't help...
# umount /tmp/OUHObyUhPi
umount: /tmp/OUHObyUhPi: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
Of course there was nothing in lsof:
# lsof | grep /tmp/OUHObyUhPi
#
dmsetup was showing my lv_name as open:
# dmsetup info -c /dev/mapper/vg00-lv_name
Name Maj Min Stat Open Targ Event UUID
vg00-lv_name 254 0 L--w 1 1 0 LVM-CqfjODkizlaDYpfk1631CZ06tTL2D2wp6kGNTj1EeCR8SPnIeE0NhSbdKZTYO4Jc
But it wasn't able to turn it off:
# dmsetup remove /dev/mapper/vg00-lv_name
device-mapper: remove ioctl failed: Device or resource busy
What worked for me, was lazy unmount:
# umount -l /tmp/OUHObyUhPi/
Then I could remove the LV:
# lvremove /dev/vg00/lv_name-disk
Do you really want to remove active logical volume lv_name? [y/n]: y
Logical volume "lv_name" successfully removed

2 comments: