Recreate a missing VMDK descriptor file April 12, 2016Posted by General Zod in Tech, VMware.
I needed to expand the disk sizes on one of my VMs, and encountered an odd problem. Under the VM Settings, all of the disk sizes were reading as 0 MB.
Honestly, I have no idea what happened, but it seemed that the VMDK descriptor files had disappeared. I don’t believe that it would have been done maliciously, yet I can think of no reason why it would have “just happened”. Regardless, the problem exists, so what to do about it?
Well, if you’re having this problem, the solution is actually pretty easy, provided you feel moderately comfortable with manipulating your VM on a file level. It might be important for your to know that I’m basing these instructions on my current use of vSphere ESXi 5.1… and I leverage thick provisioning for all of my VMDK’s. If you’re using something different, then you’ll need to adapt these instructions to suit your needs. So read on, but …
WARNING: Use this procedure at your own risk. Incorrect use of these steps may result in further problems with your VM. If you have any doubts in these instructions or your abilities, then I strongly recommend that you contact VMware Support for assistance.
OK, that being said… let’s get started.
- Shutdown the VM.
- SSH into your Host with your favorite client. (I’m fond of PuTTY.)
- Browse to the path where your VM is stored.
ex. cd /vmfs/volumes/datastore/vm
- List out the contents of the VMX file, and identify the SCSI controller type.
ex. cat vm.vmx
Then, look for a line similar to: scsi0.virtualDev = “XXXXXX”
(In this example, I’m going to presume that I’m using an LSI Logic SAS controller.)
- List the contents of the folder, and make note of the EXACT size of the vm–flat.vmdk file(s).
ex. ls –l
The output will look something like this:
-rw——- root 64424509440 Apr 6 17:50 vm-flat.vmdk
- Next, you are going to create a new VMDK descriptor file. You will need to indicate the exact size and disk type of the original VMDK, your SCSI controller type, and a DIFFERENT filename for the new VMDK.
ex. vmkfstools -c 64424509440 -a lsisas -d zeroedthick new.vmdk
- Then, you will need to rename the new descriptor file to match the original descriptor filename.
ex. mv new.vmdk vm.vmdk
- Now, use the VI editor to change the Extent Description line.
ex. vi vm.vmdk
Then, locate the # Extent Description section.
Edit the filename listed in this line to direct it to your original –flat.vmdk file.
ex. RW 123456789 VMFS "vm-flat.vmdk"
If you’re unfamiliar with the VI editor, then here’s a quick lesson.
Scroll to the filename. Hit “i” to enter insert mode. Make your changes. Hit “<Esc>” to exit insert mode. Type :wq to save and quit.
(If you screw up, then use :q! to quit without saving.)
If you’d like to learn more about the VI editor, then Colorado State University has a nifty page discussing it at https://www.cs.colostate.edu/helpdocs/vi.html
- Power ON your VM. Confirm that all is working correctly.
- Don’t forget to clean up the rogue new-flat.vmdk file that is still sitting out on your datastore.
ex. rm new-flat.vmdk