Determining if a virtual disk is attached to another virtual machine
search cancel

Determining if a virtual disk is attached to another virtual machine

book

Article ID: 324854

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This article provides steps to determine if a virtual disk is attached to another virtual machine.


Symptoms:
  • You cannot power on a virtual machine
  • You see the error:

    Unable to access a file since it is locked.


Environment

VMware ESX Server 3.0.x
VMware ESX 4.0.x
VMware ESX 4.1.x

Resolution

To determine if a virtual disk is attached to another virtual machine:

  1. Log in to the ESX server console.
  2. Run this command to see if the file is referenced in any other .vmx file:

    grep -i diskname /vmfs/volumes/*/*/*.vmx

    Here is a sample command and its output:

    grep -i virtualdisk.vmdk /vmfs/volumes/*/*/*.vmx

    /vmfs/volumes/xxxxxxxx-xxxxxxxx-xxxx-xxxxxxxxxxxx/VM/VM.vmx:scsi0:0.fileName = "virtualdisk.vmdk"

  3. If the output from Step 2 returns more than one match, the virtual disk is being referenced by more than one virtual machine. Remove the disk from one of the virtual machines.

    If you do not know the host of the virtual machine, proceed to Step 4.

  4. Run this command to check the VMkernel logs to see if the file is in use and to identify the owner:

    vmkfstools -D diskname-flat.vmdk

    Here is a sample command and the output it writes to the VMkernel log:

    vmkfstools -D /vmfs/volumes/xxxxxxxx-xxxxxxxx-xxxx-xxxxxxxxxxxx/VM/virtualdisk-flat.vmdk

    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: 10:20:00:22.731 cpu5:1040)FS3: 130: <START virtualdisk-flat.vmdk>
    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: 10:20:00:22.731 cpu5:1040)Lock [type 10c00001 offset 48226304 v 386, hb offset 3558400
    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: gen 37, mode 0, owner 00000000-00000000-0000-000000000000 mtime 221688]
    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: 10:20:00:22.731 cpu5:1040)Addr <4, 96, 156>, gen 336, links 1, type reg, flags 0x0, uid 0, gid 0, mode 100600
    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: 10:20:00:22.731 cpu5:1040)len 12884901888, nb 6144 tbz 0, zla 3, bs 2097152
    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: 10:20:00:22.731 cpu5:1040)FS3: 132: <END virtualdisk-flat.vmdk>

    In this example, 00000000-00000000-0000-000000000000 indicates that the file is not in use or locked by another owner.

    After the virtual machine is powered on, the output written to the VMkernel log appears similar to:

    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: 11:13:16:44.102 cpu3:1041)FS3: 130: <START virtualdisk-flat.vmdk>
    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: 11:13:16:44.102 cpu3:1041)Lock [type 10c00001 offset 69419008 v 436, hb offset 3200512
    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: gen 40, mode 1, owner 4a84acc3-786ebaf4-aaf9-xxxxxxxxxxxx mtime 271]
    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: 11:13:16:44.102 cpu3:1041)Addr <4, 153, 112>, gen 379, links 1, type reg, flags 0x0, uid 0, gid 0, mode 100600
    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: 11:13:16:44.102 cpu3:1041)len 8388608, nb 8 tbz 0, zla 1, bs 1048576
    YYYY-MM-DDTHH:MM:SS esxhost vmkernel: 11:13:16:44.102 cpu3:1041)FS3: 132: <END virtualdisk-flat.vmdk>

    The owner is 4a84acc3-XXXXXX-XXXXXX-XXXXXXXXX. The part highlighted in red is the MAC address of vmnic0 from the host that has the lock.

  5. Run the following command to see the information about vmnic0:

    ifconfig vmnic0

    The output appears similar to:

    vmnic0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:296556076 errors:0 dropped:0 overruns:0 frame:0
    TX packets:190731002 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:2165627030 (2065.3 Mb) TX bytes:699435263 (667.0 Mb)
    Interrupt:113 Memory:ce000000-ce012100


    The HWaddr (MAC) of vmnic0 matches the last grouping of the owner (from the VMkernel logs). This host owns the lock on the file.

Note: This example assumes that the Service Console of the ESX host is using vmnic0.