Could not power on VM / Failed to create swap file

Description

You get the following error when trying to start a virtual machine:
Power On virtual machine:Failed to power on VM.

See the error stack for details on the cause of this problem.
Time: 30/01/2013 16:28:49
Target: vmname
ESXi: esxi.whatever.local
Error Stack
Failed to power on VM.
Could not power on VM : Not found.
Failed to create swap file '/vmname/./vmname-7cfd40fc.vswp' : Not found
SharedArea: Unable to find 'testSharedAreaPtr' in SHARED_PER_VM_VMX area.


Solution

Add the following line to the virtual machine's configuration file (vmname.vmx):
sched.swap.dir = /vmfs/volumes/datastore/

(Change datastore to the datastore you want to use)

This can be done from a CLI shell or from the GUI.

To do this from the GUI:
1. Right click on the virtual machine
2. Choose "Edit Settings..."
3. Choose the "Options" tab
4. Click on "General Normal" (under Advanced)
5. Click on "Configuration Parameters..."
6. Click on "Add Row"
7. Write sched.swap.dir on the Name
8. Write /vmfs/volumes/datastore/ on the Value
9. Click on the "OK" button

Affected software:

VMware ESXi 5.x




Comments:

Comment #1 from Peter [Username: Guest] at 04/04/2013 20:24
On the ESXi Hypervisor the button in the GUI is greyed out :(
Comment #2 from Peter [Username: Guest] at 04/04/2013 20:45
Correction. Does work. The VM was running. Sorry.
But. I found my error: no free diskspace on the volume
Comment #3 from Kobi Shmueli [Username: Kobi_S] at 05/04/2013 03:55
Peter: Thanks for the update, I hope it will help others! :)
Comment #4 from Sebastian [Username: Guest] at 23/05/2014 23:16
YOU ARE THE BEST!
Comment #5 from Amir [Username: Guest] at 09/07/2014 23:13
Just to add something:
make sure the target datastore is good enough to keep swap file. In my case, I had to choose the host's datastore instead of the VM's datastore for the swap file position.

Thank you,
Amir
Comment #6 from Olaf [Username: Guest] at 04/08/2014 17:46
For one VM your Information was helpful, for the other with WIN2008R2 your information doesn't work although there are 450 GB free Diskspace. Any other ideas?
Comment #7 from Guest [Username: Guest] at 10/09/2014 13:50
Awesome! Just worked, life saver!
Can;t thank enough.
Comment #8 from aldirn [Username: Guest] at 01/06/2015 09:40
it work! great.

But have issue while migrating the vm to other hosts. (putting the swap file on my internal datastore)

Comment #9 from Guest [Username: Guest] at 18/06/2015 19:21
confirmed this worked, just added a subfolder called 'swap' to the original vm location and added the row as instructed.

Comment #10 from Sumedha Nuwan [Username: Guest] at 21/03/2016 05:05
Thanks for this, it's was a quick fix and saved my day ! and if you have more thank 1 disk. datastore name might be different.

In my case it's was /vmfs/volumes/datastore1/


Add new comment
Name:
Anti-Bots verification code (just write 1234):