Virtual machine show 0MB disk space

Recently I had a very strange issue on Vmware ESXi 6.5. Two of the virutal machines shows 0MB disks. The virtual machines and operating system did run without issues. You could stop machine, restart machine, but from VMware point of view, you couldn’t migrate or even extend disk.

I have also tried following recovery otpions (without luck)

  • remove machine from invertory and add it back on second host
  • restore machine from backup
  • check snaphosts (no one snaphot was used)
  • check VMX file and search inside if the machine pointing to snaphoted VMDK (usually 00001.vmdk)

I finally gave up and create support ticket for VMware and we have been able to resolve it by recreating the VMDK descriptors for each disk. Here are steps how to achieve it:

  • You have to enable SSH on particular host where the machine is running
  • Connect to SSH and go to vmfs/volumes/
    cd vmfs/volumes/
  • Locate on which datastore your machine is running and go to VM machine folder
  • Create temporary directory, e.g. TEMP inside the VM folder. This step is for your safety, becuase we will be working inside this temp folder so we will not rewrite any original data. This step is very important and you sholud always do it this way so you will not accidentaly destroy original data.
    mkdir temp 
  • Now list the current content of your VM folder. Use
     ls -la 

    and you sholud see somethinng like this

[root@host1:/vmfs/volumes/5828af60-b805b1e5-67ef-28f10ed2bc11/SLP-FT-APPS] ls -la
total 195172392
drwxr-xr-x    1 root     root          3640 Jan 11 00:58 .
drwxr-xr-t    1 root     root          2940 Dec  6 00:27 ..
-rw-r--r--    1 root     root           242 Dec  6 00:27 SLP-FT-APPS-7a7b605f.hlog
-rw-------    1 root     root     6442450944 Jan 11 00:58 SLP-FT-APPS-9cf8f5c1.vswp
-rw-r--r--    1 root     root            13 Jan 10 17:04 SLP-FT-APPS-aux.xml
-rw-r--r--    1 root     root          8684 Jan 11 00:59 SLP-FT-APPS.nvram
-rw-r--r--    1 root     root             0 Jan 11 00:58 SLP-FT-APPS.vmsd
-rwxr-xr-x    1 root     root          6098 Jan 11 00:58 SLP-FT-APPS.vmx
-rw-------    1 root     root             0 Jan 11 00:58 SLP-FT-APPS.vmx.lck
-rw-r--r--    1 root     root          3239 Dec 29 07:37 SLP-FT-APPS.vmxf
-rwxr-xr-x    1 root     root          5993 Jan 11 00:58 SLP-FT-APPS.vmx~
-rw-------    1 root     root       5243392 Jan 11 00:59 SLP-FT-APPS1-ctk.vmdk
-rw-------    1 root     root     85899345920 Jan 11 01:09 SLP-FT-APPS1-flat.vmdk
-rw-------    1 root     root           560 Jan 11 00:58 SLP-FT-APPS1.vmdk
-rw-------    1 root     root       6554112 Jan 11 00:59 SLP-FT-APPS1_1-ctk.vmdk
-rw-------    1 root     root    107374182400 Jan 11 01:09 SLP-FT-APPS1_1-flat.vmdk
-rw-------    1 root     root           575 Jan 11 00:58 SLP-FT-APPS1_1.vmdk
-rw-r--r--    1 root     root       2997208 Dec  6 02:16 vmware-10.log
-rw-r--r--    1 root     root       2837004 Jan 11 00:56 vmware-11.log
-rw-r--r--    1 root     root        380110 Dec  6 02:16 vmware-6.log
-rw-r--r--    1 root     root       1909306 Dec  6 02:16 vmware-7.log
-rw-r--r--    1 root     root       7848280 Dec  6 02:16 vmware-8.log
-rw-r--r--    1 root     root       2059993 Dec  6 02:16 vmware-9.log
-rw-r--r--    1 root     root        301034 Jan 11 01:08 vmware.log
drwxr-xr-x    1 root     root           700 Jan 11 00:57 vmware_11.01.2019
-rw-------    1 root     root     115343360 Jan 11 00:58 vmx-SLP-FT-APPS-2633561537-1.vswp
  • now you have to note the size of VMDK flat disk and name. In our case 85899345920 Jan 11 01:09 SLP-FT-APPS1-flat.vmdk
  • go to the temp folder you have created
    cd temp
  • run following command
    vmkfstools -c 85899345920 SLP-FT-APPS1.vmdk-d thin

    this command will create two new files

-rw------- 1 root root 60.0G Jan 11 01:54 SLP-FT-APPS1-flat.vmdk
-rw------- 1 root root 502 Jan 11 01:54 SLP-FT-APPS1.vmdk

You can remove *-flat.vmdk, becuase we just need disk decriptor. Be careful, that you are still in your temp folder

rm *flat.vmdk

Now copy newly created .vmdk file out of the TEMP folder and rewrite the original. If you want to have backup of original file, rename it first.

cd ..

mv SLP-FT-APPS1.vmdk SLP-FT-APPS1.vmdk_original

cp temp/SLP-FT-APPS1.vmdk .

Finally we have to reload setting of the machine. First we will run command to get all VMs and make a note of VMid, then we will reload it.
To get the machines run following command

vim-cmd vmsvc/getallvms

From command I got, that my machine has ID 44, so we will reload it now

vim-cmd vmsvc/reload 44

Review the results in vShpere client. If everything will be allright, we can remove our temporary folder

rm -rf temp/

Hope that somebody will find this article helpful. In any case, just do not hesitate to ask via comments. I will reply as soon as possible.

2 thoughts on “Virtual machine show 0MB disk space

Napsat komentář

Vaše emailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *