Recovery of an Accidentally Deleted Datastore.

Symptoms

A VMware administrator has been tidying up an old ESX host prior to decommissioning and has accidentally clicked Delete on a shared datastore rather than Unmount.

The datastore is not connected to any powered on VMs so the datastore content promptly disappears from all the hosts in the cluster.

Unmount or Delete

Following this an oops sound may be heard coming from the administrator and the datastore will no longer be accessible- although it may appear as an empty datastore in the GUI, it will be listed as No such device in the CLI:

1~ # ls vmfs/volumes/
2
3ls: vmfs/volumes/51de58c7-ee8dde61-48e2-b8ac6f317273: No such device or address (VMARCHIVEDS)

Cause

The VMware administrator in question has clicked Delete where they should have clicked Unmount. vSphere has then deleted the datastore partition.

Solution

Do not attempt to create a new datastore or write anything to the disk. The partition has been removed from the volume but the data is (probably) still intact. There is an excellent article in the VMware Knowledge Base- Recreating a missing VMFS datastore partition in VMware vSphere 5.0/5.1/5.5 (2046610) – which deals with how to recover the partition table. Follow these instructions and the contents of the datastore should be restored to the connected hosts in the virtual environment.