Working with lvm I have come across many a times when the logical volume removal doesn't work. I am listing down those steps to stop searching solution on google every time. Moreover the information is scattered. So I include all here.
Details
My Volume Groups = deploy
My Logical Volume = relimg
The lvremove command is used to remove. But many a times this might not work in one shot. I use a shell script to do it-
See for each
See that Open as 1 is the problem.
Now you need to use dmsetup to close.
Details
My Volume Groups = deploy
My Logical Volume = relimg
The lvremove command is used to remove. But many a times this might not work in one shot. I use a shell script to do it-
lvremove -f /dev/deploy/relimg_* while [ $? -ne 0 ];
do
sleep 1;
lvremove -f /dev/deploy/relimg_*;
done
lvremove /dev/deploy/relimg*
Can't remove open logical volume "relimg_root"Can't remove open logical volume "relimg_var"Can't remove open logical volume "relimg_swap"
dmsetup ls| grep relimg
deploy-relimg_swap (253, 28)
deploy-relimg_root (253, 26)
deploy-relimg_var (253, 27)
See for each
dmsetup info -c deploy-relimg_var
Name Maj Min Stat Open Targ Event UUID
deploy-relimg_var 253 30 L--w 1 1 0 LVM-JWRaaEr4Fpx0HGFzDuIXNgy0CDzV4KpWQ9tWYGVu3tT5sR1nAjJPc5FBM2rhT8vF
See that Open as 1 is the problem.
Now you need to use dmsetup to close.
dmsetup remove deploy-relimg_var
lvremove /dev/deploy/relimg_var
You might also get follow error on this command (dmsetup remove deploy-relimg_var)
If so, following will help
device-mapper: remove ioctl failed: Device or resource busy
Command failed
If so, following will help
- lsof, see where device is busy, stop it and do above steps again
- mount, see if logical volume is mounted, unmount and do above steps again
if you still face that issue, you can reboot the server to fix that :)
ReplyDeleteJust tried rebooting my server and indeed it worked! Thanks! :)
ReplyDeleteThank you... it works :)
ReplyDeleteThis works but it has a drawback....
ReplyDeleteIf you create an LVM snapshot using "lvcreate -s" you get 3 additional "kdmflush" processes in the process list. If you can successfully destroy it using "lvremove" they all disappear. However, if you have to use "dmsetup remove" it leaves one of the "kdmflush" processes hanging around.
As I am continously creating snapshots and destroying them this results in hundreds of unreaped "kdmflush" processes.
still not successful.
ReplyDelete# dmsetup remove linux1vg-linux1smap
device-mapper: remove ioctl failed: Device or resource busy
Command failed
both fuser and lsof didn't find anything using it.
Thank you! it helped me :D
ReplyDeleteThanks much Boss - Saved my day.
ReplyDeleteHi Vivek, you can go through the following link to resolve this kind of issue.
ReplyDeletehttp://kb.eclipseinc.com/kb/why-cant-i-remove-a-linux-logical-volume/