Author : mimartin
Topic Name : Using Swap Files
Publication Name : vSphere Resource Management
Product/Version : VMware vSphere/6.7
Question :
I cannot get ESXi 6.7u2 to honor moving virtual machine swap files. No matter what system setting I use, the swap files stay with the virtual machine. If I edit the virtual machine vmx file, ESXi overwrites my changes even after re-registering the VM. Is this a bug?
Hey PcPixel,
Have you first configured the Swap File location at Cluster level?
Yes, I believe I did. This is a stand alone ESXi install, not part of a cluster. If I look at the that data store, I can see a vswp file for the host in the root of the data store.
That configuration you are following are for the ESXi System Swap file NOT for the VM Swap File. For configuring it you should follow the next procedure: Configure Virtual Machine Swapfile Properties for the Host
Correct. that is for the VM host. However, if I do follow those instructions you posted, ESXi completely ignores them. No matter how I configure those options, the swap files for the VM's stay with the VM's. If I manually edit the VMX file to specifically place the swap file where I want it, ESXi just overwrites the setting. I deregister and regestister the VM before making that change.
If I use the first option, the swap file stays with the VM. If I use the second one, it stays with the VM (which makes sense at least). If I use the third option, it still stays with the VM.
Regardless of which of the 3 above I pick, no matter what I set this parameter to, ESXi tosses it out & overwrites it.
Could be possible that you have another configuration here: Enable Host-Local Swap for a Standalone Host ?
I'm not sure. I can only use the web vSphere client so the instructions don't totally match up. I'll see
It should match because is the same client adn version as that procedure is for Standalone host.
The only place I can find that option is inside the vmx file: sched.swap.hostLocal = "disabled" .
These two lines are present in my current vmx:
sched.swap.hostLocal = "disabled"
sched.swap.derivedName = "/vmfs/volumes/5ee29462-20daed4c-b5f8-48df37d688a4/vmswp/DUMMY/DUMMY - Firewall-4ba521df.vswp"
If I power on the VM, it tosses those out & keeps the swap files with the VM. I don't get what I'm doing wrong.
1. Browse to host:
This ESXi install it not part of a cluster at all. It's completely stand alone. I can only access it via the web client or by directly editing vmx files.
Mmm that is strange, what if you do the next:
1. Unregister the VM.
2. Download the .vmx and add the following line:
3. Create a directory for Swap files under the datastore.
4. Add the next line into the .vmx: sched.swap.dir = /vmfs/volumes/
datastore_name/dir_name
5. Upload the VMX, register and Power-On the VM.
However this is to confirm that it works is not a definitive solution as this is per VM config.
What should I add in your step 2?
Haha my bad, follow this:
1. Unregister the VM.
2. Download the .vmx.
3. Create a directory for Swap files under the datastore you want.
4. Add the next line into the .vmx downloaded in Step 2: sched.swap.dir = /vmfs/volumes/
datastore_name/dir_name
5. Upload the VMX, register and Power-On the VM.
VM set to "keep swap file with VM". Downloaded the VMX. Changed sched.swap.derivedName to sched.swap.dir="/vmfs/volumes/5ee29462-20daed4c-b5f8-48df37d688a4/vmswp/DUMMY/DUMMY - Firewall-4ba521df.vswp". Uploaded file & verified line exists. Verified folder structure exists are well. I get "Failed to power on vbirtual machine - Module "MonitorLoop" power on failed."
Unable to create a swap file. The value of 'sched.swap.dir' specified in the VM's configuration file is invalid.
This is the data store I'm trying to use:
This the current data store layout:
This happens if the path you are specifying is wrong.
Try to create a directory under the root directory called swap-files and change to this:
sched.swap.dir= /vmfs/volumes/5ee29462-20daed4c-b5f8-48df37d688a4/swap-files
Set to: sched.swap.dir="/vmfs/volumes/5ee29462-20daed4c-b5f8-48df37d688a4/swap-files/DUMMY - Firewall-4ba521df.vswp". I got the same error.
using sched.swap.derivedName doesn't work either. Puts the swap file in the VM host directory.
I also tried stopping the path at "swap-file" and it still failed as well.
Hey,
But wait, are you specifying the .swp file inside the path? If yes, do not do that, just the datastore and the folder name. Also please try to specify the Datastore name instead of the ID.
Yes, I'd been including the .swp filename as well. I was trying to keep the file consistent. I can try again with just the path. So for the datastore name, it should be [DATASTORE_NAME]/[PATH] versus /vmfs/volumes/[VOLUMEID]/[PATH], correct?