How to Relocate a Paging file on a SCSI Controller in Hyper-V 2012 R2

There are two topics I’m going to explain in this article (1) why you can’t relocate paging file to a Virtual Hard Drive connected to a SCSI Controller in Hyper-V running on Windows Server 2012 and earlier versions and (2) how you can utilize the new booting architecture introduced in Windows Server 2012 R2 to relocate paging file to a SCSI Controller.

Before you start to dig more into this, let me start off by saying that you can’t assign paging file to a Virtual Hard Disk connected to a SCSI controller in Hyper-V unless you are running Windows Server 2012 R2, which is going to be released by the end of the year.

Why you can’t relocate Paging File?

There are several logical reasons as to why you can’t relocate paging file to a SCSI Controller VHD for a virtual machine which is running on Hyper-V Windows Server 2012 and earlier versions. One of the several reasons is that the SCSI controllers are available only when you have installed “Integration Components” in a Virtual Machine. SCSI controllers, as opposed to IDE controllers, do not ship with Hyper-V BIOS. They actually ship with “Integration Components”. “Integration Components” are initialized only after Kernel Mode components have finished its job and paging file initialization takes place as part of the Kernel Mode. I’ll give you a little more detail on that.

Note: Relocating a paging file requires a reboot for changes to take effect. This is because the “Session Manager” (part of Kernel Mode) is responsible for initializing the relocated/new paging file at the time of booting. This cannot happen on the fly and that’s why the OS must be restarted for the changes to take place.

Technically speaking, you can relocate paging file to a VHD file attached to a SCSI controller and also Operating System is not going to stop you from doing this but for whatsoever reason Operating System is not going to use it for sure! You might end up having two paging files if you do so! This is because the way Operating System locates and uses paging file during boot which is explained in the below process.

This is what happens when Operating System starts:

  1. Windows Boot Manager Starts.
  2. Emulated IDE driver, which is part of Hyper-V BIOS, is loaded in the memory.
  3. Kernel Mode gains the control.
  4. Kernel Mode components are initialized and drivers are loaded in the memory.
  5.  “Session Manager” initializes itself and locates a paging file to be used by querying the following registry entries:

HKLMSYSTEMCurrentControlSetControls”Session Manager”Memory Management. 

There are two registry entries checked by the “Session Manager” to determine the current paging file location; PagingFiles and ExistingPageFiles.

6. “Session Manager” looks for the paging file in the above registry entry and initialize it.

7. If the “Session Manager” does not find any paging file at that location, it creates a paging file on the Operating System drive and resets above two registry entry values. It also shows an informational message as shown below:

Note: At this point, SCSI controllers are not loaded. Only the Emulated IDE is available for Operating System use.

8. Once the Kernel Mode components have loaded Operating System successfully, the Hyper-V “Integration Components” are initialized which includes initializing the SCSI Controller driver.

The point here is that the SCSI controller drivers are initialized and loaded only after Kernel Mode components have finished loading Operating System successfully.

How to Relocate Paging File?

Before I start explaining how you do it, let me tell you that Microsoft changed the booting architecture for Virtual Machines running on Windows Server 2012 R2 Hyper-V Server. Starting with Windows Server 2012 R2, there are two types of virtual machines you can create; “Generation 1” and “Generation 2”. “Generation 1” is same as a virtual machine running on Windows Server 2012 Hyper-V and earlier versions.

“Generation 2” Virtual Machine utilizes the new booting architecture which supports booting from a SCSI Controller Virtual Hard Disk. Booting from SCSI VHD is now possible because of a subset of “Integration Components” (including SCSI Controller driver) are loaded at Virtual Machine start-up.

Since the Operating System is able to boot from a SCSI Virtual Hard Drive, it is now possible to assign paging file to a SCSI controller Virtual Hard Disk. This is only possible if you create a virtual machine with “Generation 2” Type but again this is limited to newer guest Operating Systems like Windows 8 and Windows Server 2012.

When you create a Generation 2 virtual machine, all legacy drivers (IDE and Network adapters) are removed and a subset of “Synthetic” drivers are presented to the virtual machine. In earlier versions of Hyper-V, these Synthetic drivers are actually available when you install the Integration Service components. One thing  I want to highlight with regards to the Generation 2 technology is that Generation 2 technology was not introduced to address the  “paging file relocation problem” but to provide a set of new features which were not possible in Hyper-V running on Windows Server 2012 and earlier versions.

Apart from booting guest Operating System from a Virtual Hard Disk connected to a SCSI Controller, it is now also possible to install the guest Operating Systems from a PXE Server with the help of PXE Client. Moreover, booting and installation of an Operating System are much faster.

As you can see in below screenshot, you are provided with four booting options; booting from a file, booting from a DVD drive, booting from Network Adapter (PXE), and booting from a VHDX file.

Virtual Machine will try to boot from the order you have specified in the “Firmware” settings shown in the above screenshot.

What you see below is the screenshot of  newly created “Generation 2” virtual machine on Windows Server 2012 R2. As you can see, there are 64 SCSI channels are made available for Virtual Machine and this is, of course, without installing the “Integration Components”! This is a new virtual machine which has been created using “Generation 2” type and Operating System is yet to be installed.

You also notice that there are no IDE Controllers available in Generation 2 Virtual Machine. “Add Hardware” settings do not show anything about adding IDE Controllers and Legacy Network Adapters as shown in the below screenshot:

Shown in the red square in the above screenshot is the Synthetic drivers. So there are no legacy drivers provided with the “Generation 2” Virtual Machine and performance is better than a Virtual Machine using the IDE controllers.

Since SCSI Controllers are available before the Operating System starts, it is now possible to relocate the paging file to SCSI controller. This functionality enables “Session Manager” to initialize the paging file during boot.

The whole point here is that the “Synthetic” drivers, which includes SCSI Controller driver also, are presented to the Operating System before Kernel Mode component initialization occur which makes it possible to have paging file relocated to a SCSI Controller Virtual Hard Disk.

Conclusion

In this article we saw why it is not possible to relocate a paging file to a virtual hard drive connected to a SCSI Controller in virtual machines running on Windows Server 2012 Hyper-V and earlier versions.

With the help of new booting architecture introduced with Windows Server 2012 R2 which makes it possible to relocate a paging file to a SCSI Controller Virtual Hard Drive and also provide a number of features which were not possible in earlier versions.

 

Altaro Hyper-V Backup
Share this post

Not a DOJO Member yet?

Join thousands of other IT pros and receive a weekly roundup email with the latest content & updates!

3 thoughts on "How to Relocate a Paging file on a SCSI Controller in Hyper-V 2012 R2"

  • Brian says:

    I have an issue with creating VDI pools with Hyper-V 2012 R2 due to the lack of IDE drives. When I try I get an error stating that “A virtual hard disk is not attached to the virtual desktop”. I could wait for the full version to come out in 2 weeks but I want to do some testing and work out most of the bugs before I setup the real system and go live. Any ideas?

    • Nirmal Sharma says:

      Hi Brian,

      It’s OK if your question is not related to the post but I would like to know what you’re trying to do and what is not working?

      Would you mind be more specific please?

      Nirmal.

  • Michael says:

    I was disappointed to learn that you cannot easily migrate from Gen1 to Gen2 VMs. However, as I am currently running WHS 2011 as a Gen1 VM, it appears to be a moot point.

    I seem to have an issue with moving my paging file on the VM, and I was curious if there is really much to be gained from what has become an extended effort. I created a VHD on the “slave” IDE port of the VM, but I continue to get the annoying message about the temp paging file being created.

    The host OS is Windows 8.1, and is running on a 256GB SSD. The VM is running from a VHD on the SSD as well. My understanding was that paging files chew the crap out of SSD and should be relocated. I had attempted to relocate to one of the physical drives I passed on to the VM, but since it was “attached” via the SCSI controller of Hyper-V, it kept failing.

    If the VM is running on as SSD, will I really get any performance boost from moving the paging file? If not, should I still try to do so in order to extend the life of my SSD?

    Thanks for posting such an informative article!

Leave a comment or ask a question

Your email address will not be published. Required fields are marked *

Your email address will not be published. Required fields are marked *

Notify me of follow-up replies via email

Yes, I would like to receive new blog posts by email

What is the color of grass?

Please note: If you’re not already a member on the Dojo Forums you will create a new account and receive an activation email.