VM Template Registration Failed with Error "Unable to Write VMX File: '/vmfs/volume/datastore/VM_Name.vmtx'"
search cancel

VM Template Registration Failed with Error "Unable to Write VMX File: '/vmfs/volume/datastore/VM_Name.vmtx'"

book

Article ID: 417115

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • When attempting to register a VM template to vCenter, the process fails with the error message: 
    • Unable to write VMX file: "/vmfs/volume/datastore/file_name.vmtx"
  • Datastore location where the VM template is stored has only read only access to the file system. 
  • From /var/log/vmware/vpxd/vpxd.log
    • YYYY-MM-DDTHH:MM:SSZ info vpxd[21###92] [Originator@6876 sub=vpxLro opID=m######w-25#####8-auto-######-h5:70####79-##-01] [VpxLRO] -- BEGIN lro-88047241 -- group-v####7 -- vim.Folder.registerVm -- 52####51-####-####-####-f5b######3b6(52#####bb-####-####-####-90#######7a4)
      YYYY-MM-DDTHH:MM:SSZ error vpxd[21###92] [Originator@6876 sub=VmProv opID=m######w-25#####8-auto-######-h5:70####79-##-01] Failed to register VM on host; [vim.HostSystem:host-4###7,esxi_host.domain.com], name: VM_Name, config: ds:///vmfs/volumes/datastore/VM_Name/VM_Name.vmtx
      YYYY-MM-DDTHH:MM:SSZ error vpxd[21###92] [Originator@6876 sub=VmProv opID=m######w-25#####8-auto-######-h5:70####79-##-01] Get exception while executing action vpx.vmprov.RegisterDestinationVm:
      --> (vim.fault.GenericVmConfigFault) {
      -->    faultMessage = (vmodl.LocalizableMessage) [
      -->       (vmodl.LocalizableMessage) {
      -->          key = "msg.vigor.vmx.write.error",
      -->          arg = (vmodl.KeyAnyValue) [
      -->             (vmodl.KeyAnyValue) {
      -->                key = "1",
      -->                value = "/vmfs/volumes/datastore/VM_Name/VM_Name.vmtx"
      -->             }
      -->          ],
      -->          message = "Unable to write VMX file: /vmfs/volumes/datastore/VM_Name/VM_Name.vmtx."
      -->       },
      -->       (vmodl.LocalizableMessage) {
      -->          key = "msg.fileio.lock",
      -->          message = "Failed to lock the file",
      -->       }
      -->    ],
      -->    reason = "Unable to write VMX file: /vmfs/volumes/datastore/VM_Name/VM_Name.vmtx.",
      -->    msg = "Unable to write VMX file: /vmfs/volumes/datastore/VM_Name/VM_Name.vmtx."
      --> }
  • From /var/run/log/hostd.log
    • YYYY-MM-DDTHH:MM:SSZ In(166) Hostd[20###20]: [Originator@6876 sub=Vimsvc.TaskManager opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52####c user=vpxuser:Domain\Username] Task Created : haTask-ha-folder-vm-vim.Folder.registerVm-72###0
      YYYY-MM-DDTHH:MM:SSZ In(166) Hostd[20###20]: [Originator@6876 sub=MetadataTagExtractor opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52####6c user=vpxuser:Domain\Username] Applied tag : id [Tag rule id=rule[CreatingVm], tag=creatingVm, regex=vim\.Folder\.(createVm|registerVm)|vim\.Host\.LowLevelProvisioningManager\.(createVm|reconfigVm)|vim\.ResourcePool\.importVApp - Identifies operations that create a virtual machine] to operation: vim.Folder.registerVm
      YYYY-MM-DDTHH:MM:SSZ In(166) Hostd[20###16]: [Originator@6876 sub=Solo.HaVMFolder opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52####c user=vpxuser:Domain\Username] Register called: []/vmfs/volumes/datastore/VM_Name/VM_Name.vmtx
      YYYY-MM-DDTHH:MM:SSZ Db(167) Hostd[20###16]: [Originator@6876 sub=Vmsvc opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52####c user=vpxuser:Domain\Username] Registering virtual machine [76]: /vmfs/volumes/datastore/VM_Name/VM_Name.vmtx
      YYYY-MM-DDTHH:MM:SSZ In(166) Hostd[20###16]: [Originator@6876 sub=Libs opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52###c user=vpxuser:Domain\Username] FILE:open error on /vmfs/volumes/datastore/VM_Name/VM_Name.vmtx.lck: Read-only file system
      YYYY-MM-DDTHH:MM:SSZ Wa(164) Hostd[20###16]: [Originator@6876 sub=Libs opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52####c user=vpxuser:Domain\Username] FILE: FileIO_Lock on '/vmfs/volumes/datastore/VM_Name/VM_Name.vmtx' failed: Read-only file system
      YYYY-MM-DDTHH:MM:SSZ Db(167) Hostd[20###16]: [Originator@6876 sub=Vigor.Vmsvc.vm:/vmfs/volumes/datastore/VM_Name/VM_Name.vmtx opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52####c user=vpxuser:CDomain\Username] Set display name message: Unable to write VMX file: /vmfs/volumes/datastore/VM_Name/VM_Name.vmtx.
      YYYY-MM-DDTHH:MM:SSZ Db(167) Hostd[20###91]: --> Failed to lock the file
      YYYY-MM-DDTHH:MM:SSZ Db(167) Hostd[20###91]: -->

Environment

  • VMware vCenter Server Appliance 7.X
  • VMware vCenter Server Appliance 8.X

Cause

  • During the registration process, the system attempts a VM reconfiguration, which involves renaming the virtual machine. Since the datastore only allows read access, the rename operation fails.
  • From /var/run/log/hostd.log
    • YYYY-MM-DDTHH:MM:SSZ In(166) Hostd[20###16]: [Originator@6876 sub=Vmsvc.vm:/vmfs/volumes/datastore/VM_Name/VM_Name.vmtx opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52####c user=vpxuser:Domain\Username] State Transition (VM_STATE_OFF -> VM_STATE_RECONFIGURING)
      YYYY-MM-DDTHH:MM:SSZ In(166) Hostd[20###16]: [Originator@6876 sub=Vmsvc.vm:/vmfs/volumes/datastore/VM_Name/VM_Name.vmtx opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52####c user=vpxuser:Domain\Username] State Transition (VM_STATE_RECONFIGURING -> VM_STATE_OFF)
      YYYY-MM-DDTHH:MM:SSZ In(166) Hostd[20###16]: [Originator@6876 sub=Vmsvc.vm:/vmfs/volumes/datastore/VM_Name/VM_Name.vmtx opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52####c user=vpxuser:Domain\Username] Rename request failed - rename virtual machine from vmname to VM_Name
      YYYY-MM-DDTHH:MM:SSZ Wa(164) Hostd[20###16]: [Originator@6876 sub=Vmsvc.vm:/vmfs/volumes/datastore/VM_Name/VM_Name.vmtx opID=m######w-25#####8-auto-######-h5:70####79-##-01-48-093f sid=52####c user=vpxuser:Domain\Username] Setting name of virtual machine failed

Resolution

To resolve the issue, follow these steps:

  • Take SSH of the ESXi host and login with root credentials. 
  • Change directory to datastore where the VM template is stored. 
    • cd /vmfs/volume/datastore/VM_Name/
  • Edit the VM_name.vmtx file and modify the parameter "displayName" to required VM name i.e., "VM_Name"
    • vi VN_Name.vmtx
    • For example:
      • displayName = "VM_Name"
  • Save the file.
    • :wq!
  • Then again try to register the VM template to the vCenter.