Azure Temporary Storage Drive Letter Reassignment

 

Last month I was working for a customer who wanted to migrate some existing virtual machines (VMs) to Azure with data and applications stored on the D: drive. In the same process he wanted to upgrade from W2K8 R2 to W2k12 R2 and keep those same drive letters in place. So all VMs had to be built from scratch on the Azure IaaS platform. But like you all probably know, each new VM on Azure gets a Temporary storage disk (scratch disk) with drive letter D: So I had to come up with a workaround to use the D: as a data/application drive, which can be found below.

If you’re interested, you can find more info about the Temporary Disk via following link: http://blogs.msdn.com/b/mast/archive/2013/12/07/understanding-the-temporary-drive-on-windows-azure-virtual-machines.aspx

Before we start, two things to keep in mind:

  • The Temporary Storage drive (D:) on an Azure IaaS VM hosts the page file, so this has to be relocated before the drive letter can be changed.
  • If you attach an empty disk to an Azure VM always use the maximum size of 1 TB. When you format this disk inside the VM, always choose quick format. This way data only actually written is stored and that is what you’re charged for. This will minimize your costs.

1) Create the VM. If you do not know how follow this link: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-tutorial-classic-portal/

2) Attach an extra data disk to the VM

3) Use RDP to logon to the VM

4) Open Disk Management with choosingRun and typing diskmgmt.msc

5) The following screen will pop up. Select GPT and press OK

6) The Disk Management screen will look like the screenshot below

7) To relocate the Windows Page File (pagefile.sys) open Control Panel – System – Advanced system settings

 

8) Under Performance select Settings… Select the tab Advanced. Under Virtual memory select Change…

 

9) Select the Cdrive and then click System managed size and then click Set. Select the D drive and then click No paging file and then click Set. Click OK

 

10) A System Properties page pops up, where you need to click OK

11) Restart the VM to apply the changes

12) When the VM is rebooted, use RDP to logon to the VM and open Disk Management again

13) Right-Click the CD-ROM (E:) and select Change Drive Letter and Paths to change the drive letter to Z:

14) Right-click on D, the Temporary Storage drive, and select Change Drive Letter and Paths to change the drive letter to E:

15) Create a New Simple Volume… on Disk 2 and assign it to the drive letter D:

 

16) After all adjustments are made, Disk Management should look like this

17) Now you can move the Windows Page File back to the Temporary Storage now assigned with the drive letter E:

18) To apply the changes, reboot the VM

19) After the reboot, login to the VM and validate if everything is working fine and you don’t see a message like shown in the screenshot below.

20) To check if everything is still OK when the VM is de-provisioned, SHUT DOWN the VM from the Azure Classic portal. In this way it comes in the Stopped (Deallocated) state. Afterwards START the VM from the portal. In this case your VM will get re-deployed with its specific configuration and the Temporary Storage will be wiped, and your VM could be brought up on a different Hyper-V host in the Azure Datacenter. If everything is OK, the drive letter change for the Temporary Storage is OK and you can use this VM in production.

That ends this blog post. Till next time!

Wim Matthyssen (@wmatthyssen)

Use the D: drive as a data drive on a Windows VM

  • 2 minutes to read
  • Contributors

If your application needs to use the D drive to store data, follow these instructions to use a different drive letter for the temporary disk. Never use the temporary disk to store data that you need to keep.

If you resize or Stop (Deallocate) a virtual machine, this may trigger placement of the virtual machine to a new hypervisor. A planned or unplanned maintenance event may also trigger this placement. In this scenario, the temporary disk will be reassigned to the first available drive letter. If you have an application that specifically requires the D: drive, you need to follow these steps to temporarily move the pagefile.sys, attach a new data disk and assign it the letter D and then move the pagefile.sys back to the temporary drive. Once complete, Azure will not take back the D: if the VM moves to a different hypervisor.

For more information about how Azure uses the temporary disk, see Understanding the temporary drive on Microsoft Azure Virtual Machines

Attach the data disk

First, you'll need to attach the data disk to the virtual machine. To do this using the portal, see How to attach a managed data disk in the Azure portal.

Temporarily move pagefile.sys to C drive

  1. Connect to the virtual machine.
  2. Right-click the Start menu and select System.
  3. In the left-hand menu, select Advanced system settings.
  4. In the Performance section, select Settings.
  5. Select the Advanced tab.
  6. In the Virtual memory section, select Change.
  7. Select the C drive and then click System managed size and then click Set.
  8. Select the D drive and then click No paging file and then click Set.
  9. Click Apply. You will get a warning that the computer needs to be restarted for the changes to take affect.
  10. Restart the virtual machine.

Change the drive letters

  1. Once the VM restarts, log back on to the VM.
  2. Click the Start menu and type diskmgmt.msc and hit Enter. Disk Management will start.
  3. Right-click on D, the Temporary Storage drive, and select Change Drive Letter and Paths.
  4. Under Drive letter, select a new drive such as T and then click OK.
  5. Right-click on the data disk, and select Change Drive Letter and Paths.
  6. Under Drive letter, select drive D and then click OK.

Move pagefile.sys back to the temporary storage drive

  1. Right-click the Start menu and select System
  2. In the left-hand menu, select Advanced system settings.
  3. In the Performance section, select Settings.
  4. Select the Advanced tab.
  5. In the Virtual memory section, select Change.
  6. Select the OS drive C and click No paging file and then click Set.
  7. Select the temporary storage drive T and then click System managed size and then click Set.
  8. Click Apply. You will get a warning that the computer needs to be restarted for the changes to take affect.
  9. Restart the virtual machine.

Next steps

Comments

Leave a Reply

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