For the official recommended one from VMware pls follow this link
Storing a virtual machine swap file in a location other than the default in ESX/ESXi (1004082)
After Storage migration. VM still pointing vswp file in old datastore and unable to power on and issue a following error.
Error : unable to create a swap file. the value of ‘sched.swap.dir’
To change the swap file location for a single virtual machine:
- Power off the virtual machine.
- Unregister the virtual machine. Right-click the virtual machine in the Inventory and choose Remove from Inventory.
- Connect to the host using SSH
- browse the datastore where virtual machine is resided;
- Change directory to the folder where the virtual machine resides:
- Edit the virtual machine’s configuration file with a text editor.
- Edit vi using commands:
- Esc :i
- replace the following;
sched.swap.dir = /vmfs/volumes/old_datastore_name/dir_name
sched.swap.dir = /vmfs/volumes/new_datastore_name/dir_name
- save the vi file using command “:wq“
- Register the virtual machine again.
- PowerON VM without any error.
Note:- Resolve issue for ESXi 6 as well.
It works :).