VMware Cloud Community
AllBlack
Expert
Expert

Separating Guest OS swap with Powercli

Hi

I am in the process of separating guest os swap files so we don't have to replicate transient data to the DR site

I'd like to automate this process as much as possible. One of the steps required is to clone the vmdk that holds the template page file.

Manually it would be done like this: vmkfstools -i /vmfs/volumes/templates/pagefile.vmdk /vmfs/volumes/pagefiles/<vmname>/pagefile.vmdk.

I was wondering if I could use copy-harddisk to achieve this? Looks to me like it is achieving the same objective.

If so, I assume I'd use something like this Copy-HardDisk -HardDisk $hdd -DestinationPath "[pagefiles] <vmname>".

How can I ensure the value of $hdd is /vmfs/volumes/templates/pagefile.vmdk, keeping in mind that pagefile.vmdk template is not associated with a VM (get-harddisk -VM myvm -name "hard disk2" is not an option then)

Please consider marking my answer as "helpful" or "correct"
0 Kudos
4 Replies
LucD
Leadership
Leadership

Can't you do this with the Set-VMHost cmdlet and the VMSwapfileDatastore parameter.

And then the Set-VM with the -VMSwapFilePolicy InHostDataStore parameter.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
AllBlack
Expert
Expert

It seems to me that the cmdlet as you suggest is for specifying the VM swap file. I want to separate the guest OS swap file.
In windows, this sits by default on the system drive. The idea is that I move it to a a separate vmdk and place that vmdk in a dedicated datatore.

cheers

Please consider marking my answer as "helpful" or "correct"
0 Kudos
LucD
Leadership
Leadership

Ok, got it.

But then I don't get why you can't determine the VMDK by using the Get-Harddisk cmdlet.

Perhaps you should describe how you create a VM from the template, and then add a new VMDK to hold that swap file ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
AllBlack
Expert
Expert

Bedankt Luc,

So I have hundreds of existing VMs and they all need to have an extra disk added to hold page file.
I have followed Netapp's best practices guide which basically results in a pagefile.vmdk you keep as a template.
For each VM you want to alter you will need to make a copy of that pagefile.vmdk (manually I use vmkfstools) and store that in dedicated datastore for swapfiles. I would then edit the VM settings, add the newly created pagefile disk and re-configure Windows.

So my original pagefile.vmdk is not associated with a VM and it seems to me that I cannot use Get-harddisk as a required parameter is VM and it is not attached to a VM. Hope that makes sense 🙂


I suppose I could attach the disk to a dummy VM...

Please consider marking my answer as "helpful" or "correct"
0 Kudos