2

Update: I never found a way to move the pagefile and with Microsoft's pivot to make Nano container only I doubt there will ever be a way to do this.


I am trying to move the pagefile on a Windows Server Nano install. The page file is located at E:\ and I am attempting to move it to C:\.

So far I have tried the CIM method (WMI cmdlets do not work with Nano) to move the pagefile, I ran Get-CimInstance -ClassName Win32_PageFileSetting | Set-CimInstance -Property @{Name='C:\pagefile.sys'; InitialSize = 0; MaximumSize = 2048} with no errors however I'm pretty sure nothing is actually being changed and the pagefile did not move on reboot and still resides on E:\.

I then tried the wmic commands: wmic pagefileset create name="C:\pagefile.sys", worked with out issue. Then I tried wmic pagefileset where name="C:\\pagefile.sys" set InitialSize=2048,MaximumSize=2048, it failed with the error Invalid format. Hint: <assignlist> = <propertyname>=<propertyvalue> [, <assignlist>]. I am able to see the newly created pagefile with wmic pagefileset get and after reboot the pagefile still resides on the E:\ volume.

Each time I reboot the server I check that I can still see the pagefile present on E:\ and that the registry still shows the pagefile set for E:\. I am also unable to format or delete the E:\ volume as one would expect when the pagefile resides on it.

Persistent13
  • 643
  • 3
  • 13
  • I think you have to turn off the automatic management first, `wmic computersystem set AutomaticManagedPagefile=False` – Brian Jul 29 '17 at 00:03

1 Answers1

0

Try using the script below to disable the pagefile management, and then set the new values.

Set-CimInstance -Property @{AutomaticManagedPageFile = $False}

$PageFile = Get-CimInstance -ClassName Win32_PageFileSetting
$PageFile | Remove-CimInstance

New-CimInstance -ClassName Win32_PageFileSetting -Property  @{Name= "$("C"):\pagefile.sys"}
Get-CimInstance -ClassName Win32_PageFileSetting | Set-CimInstance -Property @{InitialSize = 4096; MaximumSize = 4096}

Source: https://richardjgreen.net/modifying-nano-server-pagefile/

Cory Knutson
  • 1,866
  • 12
  • 20