Tuesday 26 November 2013

How to recreate vmdk descriptor file

Below are the steps to recreate a missing text descriptor file for a virtual disk

Important points:

1. Make sure u backup the virtual machine configuration file
2. Make sure u have last successful backup for your virtual machine.

Steps to follow:

1. Login to ESX/ESXi server using putty session

2. Switch to virtual machine directory as show below

#cd /vmfs/volumes/<datastore name>/<virtualmachine folder>

3. list the vmdk files and check whether the text descriptor file is present or not

#ls -l *.vmdk


Pre-requisites:

4.  In order to re-create the missing text descriptor file, we should first know the scsi controller type which was being used by the virutal disk. Below command helps you to get that information

#less *.vmx | grep -i virtualdev
scsi0.virtualdev = "lsilogic"

5. Next u need to have the exact size of the virtual disk. Below command will do that for you. Copy the value as shown in the output

#ls -ll *-flat.vmdk

6. vmkfstools command will help you to recreate a missing text descriptor file.  options used are (CAD)

#vmkfstools -c <size value> -a lsilogic -d thin temp.vmdk

c - create; a - scsi controller type; d - disk type (thin or thick)

7. list the vmdk files and check whether the new descriptor file named temp.vmdk was created or not. Note that 2 files will be created text descriptor file and its associated flat file

#ls -ll *.vmdk

temp.vmdk
temp-flat.vmdk


8. rename the newly created descriptor file to your servername as shown below:

#mv temp.vmdk servername.vmdk

9. Note that your servername.vmdk file is still pointing to temp-flat.vmdk file. So edit the servername.vmdk file and point it to servername-flat.vmdk file as shown below.

#vi servername.vmdk

in extent description section change the file name

Also note that if your disk is thick provisioned then remove the line "ddb.thinprovisioned" = 1 at the last and then save the file

10. Check all the steps are correctly performed and then power on the virtual machine.