Pages

Sunday, January 20, 2013

Creating a snapshot in vSphere 4 throws the error: “Cannot complete the operation because the file or folder already exists”

Problem

Environment Information:

vCenter: 4.1.0, Build 345043
ESXi: 4.1, Build 348481

You attempt to create a snapshot for a virtual machine:

image

… but receive the following error:

Create virtual machine snapshot VirtualMachineName

Cannot complete the operation because the file or folder <unspecified filename> already exists

image

Solution

The reason why this error is thrown is because there is most likely failed snapshot attempt in the past that left over a file with the same name that your snapshot action is trying to use.  For my situation, the virtual machine didn’t even have a snapshot listed in the snapshot manager so I knew it should be fairly safe to move any snapshot files out of the virtual machine’s folder.

As the GUI for browsing the datastore doesn’t show show the delta files, one of the easiest ways to check is to SSH into a host that has access to the LUN containing the virtual machine with the failed snapshot and use the following commands:

ls -lhrt will list all of the files in the virtual machine’s folder as well as it’s attributes:

image

To narrow down the list to display only delta files (snapshots), use the command:

ls -l *delta*

image

Note how there is a orphaned delta (snapshot) file in the folder.  Proceed with using the mkdir and mv commands to create a folder and move the file into the folder.  Note that you won’t be able to move this file if this snapshot file was being used.

imageimage

Creating a snapshot should now work as the file with the name VirtualMachineName-01-000001-delta.vmdk has now been moved.

1 comment:

Anonymous said...

Terence thanks for your article it helped to solve this issue in vSphere 5.