Sometimes we need to remove vdisk from Guest LDOM online, but fail due to "Device being used by VxVM" error even we have removed the disk from VxVM configuration thus no any VxVM object is referenced by it.
Absolutely we can remove it by stopping Guest LDOM, instead here's an example how to remove it online:
1. The disk was already removed from VxVM configuration on Guest LDOM
guest-ldm # vxdisk -o alldgs list
<...snip...>
emc_clariion0_276 auto:cdsdisk - - online
2. Failed to remove vdisk on Service LDOM, even with "-f" option:
service-ldm # ldm rm-vdisk dsk276 guest-ldm
Guest LDom returned the following reason for failing the operation:
Resource Information
---------------- -------------------------
/dev/dsk/c0d24s2 Device being used by VxVM
VIO operation failed because device is being used in LDom guest-ldm
Failed to remove vdisk instance
service-ldm # ldm rm-vdisk -f dsk276 guest-ldm
Guest LDom returned the following reason for failing the operation:
Resource Information
---------------- -------------------------
/dev/dsk/c0d24s2 Device being used by VxVM
VIO operation failed because device is being used in LDom guest-ldm
Failed to remove vdisk instance
The -f option has no effect because the device cannot be removed safely
3. Try to re-scan device on Guest LDOM, still see the same error
guest-ldm # devfsadm -C
guest-ldm # vxdctl enable
guest-ldm # vxdisk rm emc_clariion0_276
service-ldm # ldm rm-vdisk dsk276 guest-ldm
Guest LDom returned the following reason for failing the operation:
Resource Information
---------------- -------------------------
/dev/dsk/c0d24s2 Device being used by VxVM
VIO operation failed because device is being used in LDom guest-ldm
Failed to remove vdisk instance
4. The solution is to disable dmpnode on Guest LDOM first, then remove vdisk from Service LDOM as normal like below:
guest-ldm # vxdmpadm disable dmpnodename=emc_clariion0_276
service-ldm # ldm rm-vdisk dsk276 guest-ldm
service-ldm # ldm list-bindings guest-ldm << the vdisk has been removed successfully from Guest LDOM
5. Check further, the corresponding dmpnode on Service(I/O) Domain is still online and all paths are enabled
service-ldm # vxdisk list emc_clariion0_276
<...snip...>
flags: online ready private autoconfig autoimport
<...snip...>
numpaths: 2
c5t500601603CE0325Dd47s2 state=enabled type=primary
c5t500601683CE0325Dd47s2 state=enabled type=secondary
5. Clear the stale device that's already removed on Guest Domain
guest-ldm # vxdisk -o alldgs list | grep 276
emc_clariion0_276 auto - - error
guest-ldm # devfsadm -C
guest-ldm # vxdisk scandisks
guest-ldm # vxdisk -o alldgs list | grep 276 << the removed disk is cleared from VxVM
guest-ldm #