Deleting virtual disks and snapshots from a VM can result in orphaned disks.
search cancel

Deleting virtual disks and snapshots from a VM can result in orphaned disks.

book

Article ID: 311886

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

The customer who is a service provider may have the issue of their customers being overcharged on storage because of orphaned disks resulting from the above steps.

Symptoms:
Virtual base disks (named similar to "foo.vmdk") are seen in a VM's directory but the disk is no longer attached to the VM. That is, the disk is not visible in any VM inventory view in the Web UI, nor can the VM see the disk when it powers-on. This can occur after performing the following steps:
1. Begin with a VM that has snapshots.
2. Remove a disk from that VM using the Web UI with the "Delete files from datastore" option enabled.
3. Remove all snapshots from the VM.


Cause

This is day-1 behavior for the VMware ESX product and was a deliberate design decision. We strive to avoid causing customer data loss under any circumstances and it was decided that ESX should never delete a VM base disk as a side-effect of another operation (such as removing all snapshots).

Resolution

In ESX 8.0U3 a new per-host advanced option called blockDiskRemoveIfSnapshot is added to address this issue. It defaults to false, but when set to true, users will be prevented from removing disks from a VM that has snapshots, even if they choose to delete files. To set this, open the VC UI, navigate to the Configure tab for the host, open Advanced System Settings, and find the entry named Config.HostAgent.plugins.vmsvc.blockDiskRemoveIfSnapshot. For easy configuration of additional hosts, the Host Profile feature will automatically preserve the value of this option."

Enable option on host via VC UI

  • Navigate to Advanced System Settings in the VC UI:

    rtaImage (1).jpeg

  • Click the Edit button in the upper-right to bring up the edit dialog and navigate to the Config.HostAgent.plugins.vmsvc.blockDiskRemoveIfSnapshot entry:
    rtaImage (2).jpeg

  • Change false to true and click OK to save the changes.
     

Enable option on additional hosts via Host Profiles

  • Please refer this link for how host profiles work.

  • Enable blockDiskRemoveIfSnapshot first on some initial host per section 2.2.1.

  • Proceed to the Host Profiles page in the VC UI and export a Host Profile from that host:
    image.png

  • Click on the newly-created profile and then click on Configure. Navigate to the following location in the hierarchy to double-check that bockDiskRemoveIfSnapshot is set to true (it won't appear here if it's still the default of false):
    image.png

  • Apply the host profile to other hosts per the documentation. They should inherit the value of this setting.

 


Workaround:
Currently there is no workaround.