Changing an Azure VM Temp Drive to T:

David Downing 706 Reputation points
2021-11-30T19:27:15.26+00:00

I need to move the Azure VM Temp Disk Drive from D: to another letter (probably T:). Because all of my provisioning setup and configuration are fully automated, I need to do this using a PowerShell script/commands.

Does anyone have a script or the commands necessary to move the temp drive from D: to another letter drive?

From several different queries, it seems like two reboots may be necessary. I did find another post that seems to indicate it's not required.

Because this automation will be used for a long time going forward, I want to do it correctly.

The VMs will be running Windows Server 2019 datacenter.

The new temp disk is already initialized and assigned to the T: drive.

Thank you,
David

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
{count} votes

Answer accepted by question author
  1. kobulloc-MSFT 26,846 Reputation points Microsoft Employee Moderator
    2021-12-07T19:31:56.433+00:00

    Hello, @David Downing !

    Changing a drive letter both manually and with a PowerShell script
    Thank you for being patient! I tried manually changing the Temporary Storage drive letter but ran into a "Parameter is incorrect" error. This was because I skipped over the prerequisite step of temporarily moving pagefile.sys to C drive like you mentioned. Once I did that, I was able to change the drive letter from D to T successfully both manually and using the PowerShell script:

    $Drive = Get-CimInstance -ClassName Win32_Volume -Filter "DriveLetter = 'D:'"  
    $Drive | Set-CimInstance -Property @{DriveLetter ='T:'}  
    

    One of the simplest approaches to scripting pagefile.sys would be:

    wmic computersystem set AutomaticManagedPagefile=False  
    

    Once that has been completed, restart the VM and the script above to change the temp drive letter will run successfully. @David Downing (thank you!) has used the following to move the pagefile.sys to the temp drive:

    wmic pagefileset where name="C:\pagefile.sys" delete  
    wmic pagefileset create name="T:\pagefile.sys"  
    wmic pagefileset where name="T:\pagefile.sys" set InitialSize=6144,MaximumSize=6144  
    

    Additional pagefile.sys options:

    155706-temp01.png

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. David Downing 31 Reputation points
    2021-12-14T19:17:38.243+00:00

    After running the test, I noticed the pagefile.sys no longer existed on any of the drives. To complete the move I ran the following and rebooted the computer.

    wmic computersystem set AutomaticManagedPagefile=False
    wmic pagefileset where name="C:\pagefile.sys" delete
    wmic pagefileset create name="T:\pagefile.sys"
    wmic pagefileset where name="T:\pagefile.sys" set InitialSize=6144,MaximumSize=6144

    2 people found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.