Storing a virtual machine swap file in a location other than the default

Posted: July 26, 2010 in VMware
Tags: ,

Moving the swap file to an alternate datastore is a useful troubleshooting step if the virtual machine or guest operating system is experiencing failures, including STOP errors, read only filesystems, and severe performance degradation issues during periods of high I/O. However, identifying and resolving the underlying overcommit or storage performance issues is still recommended to ensure environment stability.
This can also be used to store the virtual machine swap files in an alternate non-replicated datastore when using LUN snapshot technologies to ensure that you are storing the swap files in a location that is not being replicated.

ESX 3.5 and ESX 4.0

To edit the virtual machine swap file location in ESX 3.5 and ESX 4.0:

  1. Connect directly to your ESX Server host or to your VirtualCenter server using the VI Client.
  2. Click the Configuration tab for the ESX Server host.
  3. Click Virtual Machine Swapfile Location and click Edit.
  4. Specify the datastore where you want the virtual machine swap files stored.
  5. After restarting your virtual machines, ensure the swap file is located on the specified host datastore.

ESX 3.0

Add the following line to your virtual machine’s configuration (VMX) file to store the swap on a VMFS3 volume:
sched.swap.dir= “/vmfs/volumes/<volume_name>/<dir_name>”
Where <volume_name> is a VMFS3 volume
To change the swap file location:
  1. Connect to VirtualCenter or directly to your ESX Server host using the Virtual Infrastructure Client (VI Client).
  2. Select either a virtual machine or a virtual machine template that you want to modify.
  3. Stop the virtual machine if it is running.
  4. Connect to the ESX console using SSH or service console connection.
  5. Change directory to the path of the .vmx file you want to edit.
    Note: Use the ‘vmware-cmd –l’ command to find the path to the configuration file. For more information on the vmware-cmd command, see the
    VMware Scripting API .
  6. Open the configuration file and add the line sched.swap.dir= “/vmfs/volumes/<volume_name>/<dir_name>”.
  7. Delete the line sched.swap.derivedName = xxx.
  8. Restart the virtual machine if it’s not a template.
  9. Repeat as necessary for each existing virtual machine
Advantage :
Faster VM Booting, Better VM Performace, Faster vMotioning and DRS, Faster VM evacuation when ESX host is entering maintenance mode
Ref :
  1. Marcin says:

    If I’d put swap files on separate non-raid local disk for performance increase – what would happen if this disk would fail ? Would VMWare create swapfile in guest’s machine folder after reboot would it just crash ?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s