Hyper-V VM Performance Tip: Move the Page File (pagefile.sys) to Another Virtual Disk
Your Virtual Machine Guests in Hyper-V should be treated like any other Operating System. They should be updated, defragmented, monitored, and fine tuned for performance.
Here is the primary link you will want to reference for installation, configuration, and performance of Hyper-V Virtual Machines: http://technet.microsoft.com/en-us/library/cc753637(WS.10).aspx (Don’t forget to use the Best Practices Analyzer for Hyper-V!)
Specifically, we want to focus on one area in this Perfomance Tip: Creating a Swap Disk to store the Paging File (Pagefile or pagefile.sys). Just like a physical box, the virtual machine can gain performance by moving the Paging File off of the boot drive. This can be acheived as follows:
1) Shutdown your Virtual Machine.
2) Create a Fixed Virtual Disk that is 1.5 times the amount of RAM your Virtual Machine is using. Example, if your VM has 4 GB allocated to it, your Fixed Disk would be 6 GB (I prefer 2 times the amount in my builds, so mine would be 8 GB). If you can store the Fixed Disk on a really fast drive, such as an SSD, the better off you will be. As a general rule, if you can’t afford an SSD (and who can!), try to make sure that your physical hard disks are operating at 7200 RPM or more. It is important to note that the best gains will be achieved by having this fixed virtual disk on a separate physical disk/controller than your boot virtual disk.
3) Attach the Fixed Virtual Disk to your Virtual Machine as an IDE to the second IDE Controller (IDE Controller 1). It is critical that you attach the disk as an IDE and not SCSI as the SCSI controller is synthetic (Its the same reason why you can’t boot from it).
4) Start up your Virtual Machine.
5) With your Swap File (the Fixed Virtual Disk) now in place, you can move the page file by the following. Please note that these instructions are for Server 2008 R2 SP1 but apply to other Windows based Operating Systems:
– Right click on Computer and select Properties, then select Advanced system settings.
– Under the Advanced tab, in the Performance section, select Settings.
– Under the Advanced tab of Performance Options in the Virtual memory section, select Change.
– Uncheck “Automatically manage paging file size for all drives”.
– Set a Custom Size of 1.5 times your VM memory (or 2 times in my case) on the Fixed Disk you determined to use as your Swap Drive. The Initial and Maximum Size should be the same. Example. if 8 GB is 2 times your physical memory, set the Initial and Maximum to 8 GB.
– Reboot your Virtual Machine.
– IMPORTANT: Upon reboot, go back to the Virtual memory settings and make sure to leave at least 16 MB (by setting the Intial and Maximum Custom Size to 16 MB) on the boot drive for paging. While we are moving the primary load to another disk, you may need this in case your Swap Drive becomes unavailable!
– Reboot one final time and enjoy the increased performance.
I was thinking of putting together a stripe of 10k or 15k hdd’s to hold just page file vhd’s for some of the vm’s I have running. Using your method, do you think this would be of use?
This would be useful as the IO load is being shifted to other disks. I would also look at some of the free benchmark software out there to see the before and after effects of performing such a move. Nothing beats a measurable baseline.
wow kelly.. great post.. I was having issues with my virtual machine on hyper-v which wouldn’t allow me to move the paging file to any other disk other than the C drive.. your comment about SCSI not supported (point 3) saved a lot of time troubleshooting.
Thanks,
Michael
Happy to help Michael. Best of luck with your Hyper-V endeavors!
Kelly
Hi, I presume your artcile is aimed at non-clustered environments and not using shared storage? If you move the pagefile to a seperate VHD but that is on the same storage subsystem / controller then I cant see how you would get a performance benefit?
Hi Madshark,
You are correct, the greatest gains would be on a separate disk/controller. You might see some very slight gains on the same disk/controller since a VHD is encapsulated, but the best bet woudl be to move to separate storage.
Good luck,
Kelly
Hi, if I follow the article I finally have a 2 page file.
In my case, one of D partition of 12Go and one on C partition of 16Mo.
After rebooting, I have one file of 12Go in partition B and one of 16Mo in partition C.
In the Advanced tab, in the Performance section, just above Settings, I see 12302 (16 + 12286) for Total paging file size for all drives.
I’m wondering which page file is used by the OS? How do you know that Windows use the D one by default? (Because its size is more important?)
Thanks.
PS : you can add in the article to not put a page file in a partition with the letter A or B, that doesn’t work 🙂