關於lvremove刪除openstack cinder volume所對應的邏輯卷的方法

按照個人理解,openstack裏的cinder volume建立、管理磁盤實際是用tgtadm管理的來自網絡中的lvm磁盤。網絡

有時cinder volume一直處於creating狀態或者deleting狀態,下層磁盤用不了也刪不掉,佔了很大的磁盤空間。既然它是用lvm管理的因此能夠用lvm相關的工具來刪除它。app

先找到要刪除的volume的lvm路徑,個人是:/dev/cinder-vol/volume-725230c0-558a-422a-b9aa-5f309ed42798 工具

直接lvremove /dev/cinder-vol/volume-725230c0-558a-422a-b9aa-5f309ed42798 spa

結果報錯:device-mapper: remove ioctl on  failed: Device or resource busy。好吧設備繁忙。ci

再看:dmsetup info -c /dev/cinder-vol/volume-725230c0-558a-422a-b9aa-5f309ed42798rem

Name                                                         Maj Min Stat Open Targ Event  UUID                                                                get

cinder--vol-volume--725230c0--558a--422a--b9aa--5f309ed42798 252   5 L--w    1    1      0 LVM-CMpL6mPY7LjVj3tIuF3YNvDyBtXqsmymJRiBrju5UXaoeWXxPqvAx9cLX3DlNTZIio

能夠看到open 爲1說明它被打開了,因此remove不掉。
ioc

看看是誰打開的:map

fuser -m /dev/cinder-vol/volume-725230c0-558a-422a-b9aa-5f309ed42798 

/dev/dm-5:            5214

它對應的下層塊設備是/dev/dm-5,多是由於它被mount了因此嘗試:umount /dev/dm-5

umount: /dev/dm-5: not mounted

結果是沒mount。。

看來應該是由於tgtd使用了這個邏輯卷,查看一下:

tgtadm --op show --mode target|grep 7252

Target 3: iqn.2010-10.org.openstack:volume-725230c0-558a-422a-b9aa-5f309ed42798

            Backing store path: /dev/cinder-vol/volume-725230c0-558a-422a-b9aa-5f309ed42798

果真,刪除之:tgtadm --op show --mode target --op delete --tid 3

再來看看文件打開狀態

dmsetup info -c /dev/cinder-vol/volume-725230c0-558a-422a-b9aa-5f309ed42798

Name                                                         Maj Min Stat Open Targ Event  UUID                                                                

cinder--vol-volume--725230c0--558a--422a--b9aa--5f309ed42798 252   5 L--w    0    1      0 LVM-CMpL6mPY7LjVj3tIuF3YNvDyBtXqsmymJRiBrju5UXaoeWXxPqvAx9cLX3DlNTZI

好了如今能夠刪除了:

lvremove /dev/cinder-vol/volume-725230c0-558a-422a-b9aa-5f309ed42798 

相關文章
相關標籤/搜索