VMFS Recovery™
Recover data from damaged or formatted VMFS disks or VMDK files
Recover data from damaged or formatted VMFS disks or VMDK files
Last updated: Oct 07, 2024

How to Recover Orphaned Virtual Machines (VMs)

“Orphaned” files are simply files that are no longer saved in their actual parent directory. Similarly, orphaned virtual machine refers to VM files that are not stored on their actual host or server environment. Some people may refer to these files as “Clutters” and delete them to free up space.

Yes, orphaned files can take up a lot of space, limiting the amount of free space where new data can be saved. But of course, you put back orphaned files into their actual directory (if still needed). If you need to delete orphaned virtual machines from your server environment or wish to recover them, this article provides a detailed guide to follow for each.

What Is an Orphaned VM?

Put simply, an orphaned VM is a virtual machine file that is not saved in the virtual machine. For example, a VM file (VMF.vmx) belongs to Virtual Machine A (VM-A), but it is saved in Virtual Machine B (VM-B) directory, so the VM file (VMF.vmx) is an orphaned file since it is not in the VM-A’s directory.

You can recover the file back to VM-A if it is important, or delete it from VM-B’s directory to free up space for VM-B’s data to be saved. An orphaned file may contain very important data belonging to a virtual machine – without which, that virtual machine won’t power or run smoothly. In that case, you need to recover the orphaned file and put it back to the VM it belongs.

On the flip side, an orphaned VM file may just be a clutter that needs to be deleted. Whichever it is to you, there are ways to handle these files. (Note: don’t be quick to delete an orphaned file, it may be a really useful file for one of your “not-often-used” VMs). Also, always verify before flagging a VM file as “orphaned.”

Tip: what is VM sprawl?

How to Verify Orphaned Status

In most cases, an orphaned virtual machine will show as “orphaned.” The orphaned tag will be appended to the VM name – that’s the easiest way to identify an orphaned VM. It is important to note that “orphaned” is different from “invalid.” If your VM shows an “invalid” tag, it’s a whole different case from being orphaned.

An invalid VM could mean that your vSphere ESXi host is not responding at the moment or has disconnected. Also, if for whatever reason your vSphere ESXi host files become orphaned, the VM may show with an “invalid” tag.

Here are some commands that can help you find orphaned VMs in vCenter:

Use the cell management tool and write this command: cell-management-tool find-orphan-vms options

This will print and show you versatile details about your VMs, including orphaned virtual machine files and where they are located. The Cell Management command works for VMware Cloud Director from v10.4 upwards. When you locate these orphaned VMs, you can delete them or restore them to their primary directory.

Why Do VMs Become Orphaned?

There are a few reasons why your VM is orphaned. Of course, these all point to “errors,” which could be system-based or human-based.

1. Host Failover

The most common and relatable reason why VMs become orphaned is due to host failover issues. When there’s an unsuccessful host failover or a VM is not directly registered to a host, the VM files could become orphaned.

Of course, if this is the case, you just need to move the virtual machine to the same host in your data center where the VM files are stored. Nevertheless, other reasons why VMs could become orphaned are linked to human errors, misconfigurations, or hardware failure.

2. Incomplete Migration

Migrating a virtual machine from one host to another might seem like a seamless task to an IT professional, but sometimes, things could go south. Errors during migrations, or for whatever reason your migration didn’t run completely, can cause orphaned VMs.

3. Deleted Files

There are times you may want to delete a virtual machine to troubleshoot a problem or complete a server setup. Sometimes, things could go wrong and the deletion process won’t run completely, causing the VM files to be cluttered in different directories.

4. Misconfigurations

This is rarely the cause, but then, it happens too. Any misconfiguration done when setting up or migrating a VM cause lead to issues such as having an orphaned virtual machine.

Difference Between Invalid and Orphaned Virtual Machines

In simple contrast, in a vCenter Server environment, an “orphaned” VM is one that exists in the Server database but is not present/saved in the ESX host inventory, while an “invalid” virtual machine is inaccessible due to ESXi host issues or corrupt/lost VM configuration files.

Apparently, if a virtual machine is orphaned, it will show along with the VM’s name – the same applies if the virtual machine is invalid. For example, if a virtual machine named “test-A” is orphaned, it will show as test-A (orphaned).   If it’s invalid, the orphaned tag will be replaced with “invalid.” That’s how you identify a VM that falls within these categories.

Both invalid and orphaned VMs won’t run since they have missing files or misconfigured settings. You have to fix the respective issue before they can run. Fixing these VM issues can be done with one similar procedure – move the orphaned VM to the directory where its files are stored, and for invalid VMs, trace the issue and reconfigure or power on your host.

How Do You Recover or Remove Orphaned Virtual Machines (VMs)?

As hinted earlier, don’t be in haste to delete orphaned VMs or their files. But well, you can still recover them using a professional data recovery software. However, if you allow too many orphaned VM files to clog your storage, you will have less space for important (new) data. That said, here is how to handle orphaned virtual machines.

This guide is for vSphere 6.5 or above:

  • Identify the datastore that contains the VM’s configuration file (xxx.vmx)
  • Launch your vSphere web client inventory and select the virtual machine
  • Navigate to the “Datastores” tab and open the datastores you see in this tab until you locate the one with the orphaned VM’s configuration file.
  • Verify the actual file location
  • Now, go back to the virtual machines tab and right-click the orphaned one, go to All Virtual Infrastructure Actions 🡺 Remove from Inventory 🡺 Yes.
  • Reregister the VM with the vCenter Server.
  • Go to the datastores tab and right-click on the datastore with the VM’s files - select Register VM.
  • Now browse and select the .vmx file and click OK
  • Choose a location for the VM and choose a host it will run on
  • Click Finish and you’re done.

Make sure that you first identify the configuration file’s location before registering the VM and fixing the issue. If you wanted deleting the orphan files, the procedure is the same as deleting any other file from your server or you can go through the manual process of using Power CLI.

  • Launch the PowerCLI utility and search for the orphaned VM using the connection state: ExtensionData.Runtime.ConnectionState
  • Run the Remove-VM command (cmdlet) to delete the orphaned VMs.

On the other hand, if you need to recover orphaned VMs, you need a data recovery utility.

Recover Orphaned Virtual Machines (VMs)

First things first, you have to verify the VM files' integrity and ensure that you have enough free space where the recovered files will be saved. Download and install a professional DiskInternals VMFS Recovery software on your PC to continue.

  • Step One: Launch DiskInternals VMFS Recovery and your drive’s filesystem
  • Step Two: Choose a recovery mode – it is better to choose “Full Recovery” mode – and start the scan.
  • Step Three: Select a Power Search feature that suits your “time” and DiskInternals VMFS Recovery will launch a scan to recover your files.
  • Step Four: The recovered files will be marked with an asterisk, identify the lost VM files, and save them to storage. But, you must have DiskInternals VMFS Recovery PRO version to save the recovered files.

When you have recovered the orphaned VM files, deregister it in vCenter and follow the steps explained earlier in this article to recover the VM and make it stop being an “orphaned” VM. DiskInternals VMFS Recovery is intuitive to use and integrates RAID recovery features.

Can Server Management Tools Be Helpful?

Yes, some people use server management tools to monitor and manage their VMs. An ideal tool that serves well for this purpose is the SolarWinds Virtualization Manager (VMAN). This tool is compatible with VMware and Hyper-V hypervisors for on-premises, hybrid, or cloud-based infrastructures.

When you set up and launch this software, it lets you access all your virtual machines from a personalized dashboard where you can view the virtual machine’s status and performance details such as memory ballooning, phantom files, datastore latency, and high CPU utilization. The built-in sprawl management tool lets you power off idle VMs, delete orphaned VM files, or take snapshots.

When you choose a third-party server management tool, you can recover or delete orphaned VMs without logging in to vCenter directly. Furthermore, some highly advanced server admins use scripts to automate orphaned VM recovery or deletion. It’s all about preference.

How To Remove Orphaned VMs

If you’re using a management tool, right-click on the orphaned VM and select delete. This is only advisable if you’re certain that you do not need or use the VM. But regardless, it is best to run a full backup before deleting or running any advanced action on vCenter.

Best Practices for Preventing VM Orphaning:

Somehow, there is little to nothing you can do to prevent this occurrence, depending on the scenario. If you have a server failover, chances are that you will end up with an orphaned VM, similarly, if you were transferring a VM and the transfer got corrupted, you may have an orphaned VM too.

So, basically, how to prevent orphaned VMs is to avoid having interrupted transfers or server failures. Also, human errors such as mistaken deletion of VM files can lead to having orphan VMs. Just keep your files backed up regularly, so you can always retrieve any file that goes missing and happens to play an important role in your VM setup.

But not to forget, other best practices to prevent having orphaned VMs include running regular audits, documenting your virtual environments, and using automation tools for VM lifecycle management.

Summary

Conclusively, orphaned VMs can be recovered or deleted to free up storage space; this can be done in many ways, including using server management tools. Orphaned VMs are naturally not harmful – just that they occupy space in your datastores. The guides in this article work for all VMware products.

Related articles

FREE DOWNLOADVer 4.23, WinBUY NOWFrom $699

Please rate this article.
51 reviews