Using the ESXi command line to find the virtual machine file path and virtual disk information
search cancel

Using the ESXi command line to find the virtual machine file path and virtual disk information

book

Article ID: 341663

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This article provides intormation to gather the configuration file path and virtual disk information for a virtual machine (VM) using the ESXi command line.

For a VM containing many virtual drives, this method can be more efficient than gathering the data through Edit Settings in the vSphere Client.

Environment

VMware vSphere ESXi 7.0.0
VMware vSphere ESXi 6.7
VMware vSphere ESXi 6.0
VMware vSphere ESXi 6.5

Resolution

  1. Connect to the ESXi host using an SSH session and root credentials.
  2. Find the path where the VM configuration file (.vmx) resides:
  • Find the VM in the vmInventory.xml:
cat /etc/vmware/hostd/vmInventory.xml |grep -i vm_name |grep vmx
For example:
image.png
The file path is highlighted in yellow, and the VM configuration file name (*.vmx) is highlighted in blue
  • Using the vim-cmd:
vim-cmd vmsvc/getallvms |grep -i vm_name
  1. Navigate to the VM directory from step 2:
cd configuration_file_path
  1. Run this command to get the names of the virtual disk files currently attached to the VM:
cat VM config file name |grep fileName

Notes:
  • The output will also include such other devices as virtual floppy disks and virtual DVD/CDROMs
  • Virtual disks may not be located in the same location as the .vmx file.

Additional Information

Performing common virtual machine-related tasks with command-line utilities
Troubleshooting virtual machine snapshot descriptor problems