Translate

Total Pageviews

My YouTube Channel

Monday, 28 October 2013

Cannot deploy a virtual machine from a template because the template VMDK file is locked (1007487)

Symptoms

  • Cannot deploy a virtual machine from a template
  • The template's <vm name>-flat.vmdk or <vm name>.vmdk file is locked by a running virtual machine
  • The VMDK file is not found
  • When deploying a template the option to Edit virtual Hardware (Experimental) is selected and the disk size has been modified

Resolution

This issue is resolved in VMware vCenter Server 5.0 Update 2 and vCenter Server 5.1 Update 1.
  • To download vCenter Server 5.0 Update 2, see VMware Download Center.
  • To download vCenter Server 5.1 Update 1, see VMware Download Center.

    Note
    : If updating vCenter Server is not an option, follow the steps below to work around the issue:

A virtual machine deployed from a template locks the template's VMDK files if it is incorrectly configured to run on the template's virtual disk and VMDK file instead of its own. The lock prevents other virtual machines from being deployed from the template.
 
You must determine if the template's VMDK file is locked by another virtual machine, and if so, release the lock on the files.
 
Caution: Since a virtual machine was running on the template's disk, there may have been unwanted changes to the disk. As such, a good backup and recovery plan is essential to production environments.
 
To determine if the template's VMDK file is locked by another virtual machine:
  1. Login as root to the ESX host.
  2. Change to the working directory of the template.
  3. Run the command:
    vmkfstools -D <virtual disk file> | tail -f /var/log/vmkernel | grep -i owner

    Note: In ESXi 5.x, run this command:
    vmkfstools -D <
    virtual disk file> | tail -f /var/log/vmkernel.log | grep -i owner
  4. If there are (non-zero) numbers and letters near the end of the output, a MAC address has been associated with this VMDK and another virtual machine has a lock on this file. If there are zeros at the end of the output, the VMDK file is not locked by another virtual machine.
To release the lock on the template's VMDK file:
  1. To show which virtual machine on a single host has the lock, run the command:

    grep -lr <virtual disk file> /vmfs/volumes/*/*/*.vmx

    Note: Record the full path to the virtual disk file. If this fails because of locked files try one of the methods below. This may be the case if the virtual machine disks are on storage shared between multiple hosts:

    Alternate methods:
    • grep vmx /etc/vmware/hostd/vmInventory.xml | sed -e 's/>/</g' | awk -F\< '{print $3}' > vmx;
      IFS=$(echo -en "\n\b"); for i in `cat vmx`; do echo grep -H vmdk $i; done
    • Connect-VIServer -server localhost
      Get-Vm | Get-Harddisk | Where {$_.Filename -match "<diskname>"}
  2. Power off the virtual machine that has the lock. If you cannot power off the virtual machine, seePowering off an unresponsive virtual machine on an ESX host (1004340).
  3. Edit the virtual machine's settings and remove the virtual disk, but do not delete it.
  4. To connect an existing disk:
    • In the Add Hardware Wizard, click Hard Disk > Next.
    • Select the type of storage for the virtual machine’s disk.
    • Click Next > Use an existing virtual disk.
    • Browse to the path of the virtual disk file identified in Step 1.
    • Click Next.
Source:-

No comments:

Post a Comment