Sharing

2011年10月19日 星期三

Why cannot remove logical volume?


今天想要把兩個 volume 合併起來, 所以計劃把 volume 1 砍掉, 然後 extend volume0, 但想不到竟然無法砍成功

這個是原本的狀態
root@ubuntu1104-64-6:/etc/ceph$ lvscan
  /dev/dm-3: read failed after 0 of 4096 at 0: Input/output error
  ACTIVE            '/dev/ubuntu1104-64-6/root' [45.86 GiB] inherit
  ACTIVE            '/dev/ubuntu1104-64-6/swap_1' [23.99 GiB] inherit
  ACTIVE            '/dev/ubuntu1104-64-6/lvol0' [50.00 GiB] inherit
  ACTIVE            '/dev/ubuntu1104-64-6/lvol1' [50.00 GiB] inherit

先試了一下另一台 Server, 很順利的砍掉, 完全沒有問題
root@ubuntu1104-64-5:/etc/ceph$ lvremove /dev/ubuntu1104-64-5/lvol2
Do you really want to remove active logical volume lvol2? [y/n]: y
  Logical volume "lvol2" successfully removed

試一下網路上的教學, 先把 volume 設成 inactive, 但想不到竟然也失敗!
root@ubuntu1104-64-6:/etc/ceph$ lvchange -an -v /dev/ubuntu1104-64-6/lvol1
    Using logical volume(s) on command line
  /dev/dm-3: read failed after 0 of 4096 at 0: Input/output error
    Deactivating logical volume "lvol1"
    Found volume group "ubuntu1104-64-6"
  LV ubuntu1104-64-6/lvol1 in use: not deactivating

第二招是使用更底層的指令, dmsetup 來砍, 也失敗!
root@ubuntu1104-64-6:/etc/ceph$ dmsetup remove /dev/ubuntu1104-64-6/lvol1
device-mapper: remove ioctl failed: Device or resource busy
Command failed


用 dmsetup 看一下他的狀況, Open = 1 , 想了一下可能是有某個 process 還在用這個 volume
root@ubuntu1104-64-6:/etc/ceph$ dmsetup info -c /dev/ubuntu1104-64-6/lvol1
Name                    Maj Min Stat Open Targ Event  UUID                                          
ubuntu1104--64--6-lvol1 251   3 L--w    1    1      0 LVM-j8BFBw1hbMLXLb4PCFPraeHAaodggpk2S8Wp56e6pUM8peKY22w0V5QMy8hSn3aA

用 lsof 來看一下有沒有 process 在使用, 啥! 也沒有@@
root@ubuntu1104-64-6:/etc/ceph$ lsof /dev/ubuntu1104-64-6/lvol1

突然想到前兩天有玩 iscsi, 該不會我有 export 出去吧.. 咦.. 好像是喔!
root@ubuntu1104-64-6:/etc/iet$ /etc/init.d/open-iscsi stop
 * Disconnecting iSCSI targets
   ...done.
 * Stopping iSCSI initiator service
   ...done.
root@ubuntu1104-64-6:/etc/iet$ /etc/init.d/iscsitarget stop
 * Removing iSCSI enterprise target devices:
   ...done.
 * Removing iSCSI enterprise target modules:
   ...done.

把 iscsi 停下來後, 總算砍成功啦!
root@ubuntu1104-64-6:/etc/iet$ lvremove /dev/ubuntu1104-64-6/lvol1
  /dev/dm-3: read failed after 0 of 4096 at 0: Input/output error
Do you really want to remove active logical volume lvol1? [y/n]: y
  Logical volume "lvol1" successfully removed


把 vol0 extend 成 200G, 任務完成!
root@ubuntu1104-64-6:/etc/iet$ lvresize -L +150G /dev/ubuntu1104-64-6/lvol0
  Extending logical volume lvol0 to 200.00 GiB
  Logical volume lvol0 successfully resized
root@ubuntu1104-64-6:/etc/iet$ lvscan
  ACTIVE            '/dev/ubuntu1104-64-6/root' [45.86 GiB] inherit
  ACTIVE            '/dev/ubuntu1104-64-6/swap_1' [23.99 GiB] inherit
  ACTIVE            '/dev/ubuntu1104-64-6/lvol0' [200.00 GiB] inherit


沒有留言: