VMware Cloud Community
RajuVCP
Hot Shot
Hot Shot
Jump to solution

Moving VM swap file location to another Datastore

Hi All,

Was in a task to move the 1000's of VM's swap file location to another datastore which is newly assigned to us from the existing swap file datastore which is going to be decomissioned.

Eager to check if any one did moving VM's swap file location from one datastore to another, and what all the steps taken to move.

Does it require VM downtime?

Thanks a ton in advance.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos
1 Solution

Accepted Solutions
Prakas
Enthusiast
Enthusiast
Jump to solution

Yes it is possible without downtime to VMs.

1. Make sure your cluster is configured to use swap datastore specified by host

2. Take a host in the cluster to maintenance mode, change the VM swapfile location setting to point to new datastore

3. Do this for all the hosts in the cluster

When you vMotion a VM from one host to another the swap file will get moved to new datastore. Eventually when you take all the hosts to maintenance mode and release back, vMotion occurs for every VM in the cluster and swap file gets moved.

View solution in original post

0 Kudos
3 Replies
Prakas
Enthusiast
Enthusiast
Jump to solution

Yes it is possible without downtime to VMs.

1. Make sure your cluster is configured to use swap datastore specified by host

2. Take a host in the cluster to maintenance mode, change the VM swapfile location setting to point to new datastore

3. Do this for all the hosts in the cluster

When you vMotion a VM from one host to another the swap file will get moved to new datastore. Eventually when you take all the hosts to maintenance mode and release back, vMotion occurs for every VM in the cluster and swap file gets moved.

0 Kudos
RajuVCP
Hot Shot
Hot Shot
Jump to solution

Thanks Prakash for your quick response.

I will try the steps given by you .. Thanks a lot.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos
CoolRam
Expert
Expert
Jump to solution

you can automate the task using the powerCLi script. so the manual work and chance of error will be eliminated. 

this script will get the swap file location u can modify this to migrate to another datastore.

$dsTab = @{}
Get-Datastore | %{
 
$dsTab[$_.Name] = $_.FreeSpaceGB
}

Get-VM | %{
 
$ds = $_.ExtensionData.Layout.Swapfile.Split(']')[0].TrimStart('[')
 
$_ | Select Name,@{N="Swap DS";E={$ds}},@{N="Free GB";E={[math]::Round($dsTab[$ds],1)}}
}

If you find any answer useful. please mark the answer as correct or helpful.
0 Kudos