Every Windows Server has a page file and Windows Server 2008 Server Core installations are no exception. Neither should they be an exception when it comes to tuning the page file for optimal performance and reliability.
What the page file is
The page file is usually described as a file that allows to use disk storage for data that do not fit into physical RAM. Other names for the page file are the 'swap file' and the 'paging file'. Most administrators wouldn't mind their page file settings, since they stuffed the server with RAM. Windows will always use the page file however, regardless of the amount of physical RAM.
The page file is located on the boot partition (or volume) by default, represented with the C:\pagefile.sys file. After a clean install the initial size of the file varies with the amount of physical RAM in the server.
Page file best practices
There are a couple of page file best practices:
- Make your page file a fixed size and make your page file size roughly between 1,5 and 2,5 times larger than the amount of physical RAM.
- Place your page file on a separate partition (or volume) to prevent page file defragmentation. A non-fragmented page file allows for better page file performance than a fragmented page file since the head of the hard disk won't have to skip to the next part of the page file.
Windows Server 2008 Full installations and Server Core installation both share the same installer routine up to a certain point. Because the check for the system requirements is done before choosing a specific Windows Server 2008 version the same memory requirements for Full installations and Server Core installations apply.
Default page file settings in Server Core
By default Server Core installations of Windows Server 2008 have an automatically configured page file, which is roughly 2x the size of the physical RAM.
Since Server Core doesn't have explorer.exe as its default shell I think it's a good thing Server Core has an automatically configured page file. The Operating System will adjust the size of the page file according to the needs of the box. It's unlikely you will run into serious problems as long as you have thought your server dimensions through and do not install memory leaking (web)applications.
Page file Management
Microsoft has decided to change Page File Management in Server Core around the Beta 3 era. In early versions of Server Core you could use the SCregEdit.wsf script with the PF switch. I included the command line switches for these early versions to complete this post.
Windows Server Codename "Longhorn"
In the Windows Server Codename "Longhorn" era (up until 3 weeks after Beta 3) you needed to use the SCregEdit.wsf script to manage Server Core's page file. SCregEdit.wsf was Server Core's own Registry editing tool for editing multiple related registry values. If you're a frequent visitor to this blog you've seen it used to change Automatic Update settings.
View page file settings
You can use SCregEdit.wsf to view page file settings with the following switches:
cd C:\windows\system32
cscript SCregEdit.wsf /PF /v
Change page file settings
Using SCregEdit.wsf you can not only view the Automatic Update and Page File settings, but also control the page file settings. To change the page file configuration simply type:
cd C:\windows\system32
cscript SCregEdit.wsf /PF PageFileSize PageFileSize
This command will automatically disable the automatic configuration of the page file settings.
Windows Server 2008 (post-Beta 3)
The PF switch in SCregEdit.wsf has been deprecated in the latest versions of Windows Server 2008. It can not be used in builds later than Beta 3.
I feel leaving SCregEdit.wsf for page file management was a good idea. It wasn't possible to change the location of the Page File with SCregEdit.wsf and it therefor wasn't possible to move the Page File from the default C:\pagefile.sys location to a different location.
The Server Core team must have thought: "Since Server Core has the Windows Management Instrumentation Console (wmic.exe) onboard, why not use it?"
In the Windows Management Instrumentation (WMI) the automatic page file and the set page file have different aliases:
- (wmic.exe) pagefile is used for the automatically configured page file
- (wmic.exe) pagefileset is used for the user configured page file
View automatic page file settings
You can check the automatic page file settings by typing:
wmic.exe pagefile
or
wmic.exe pagefile list /format:list
This command will return the values for allocated base size, current usage, description, installation date, name, peak usage and status. I prefer the latter command because it outputs in a more humanly readable format.
View user defined page file settings
You can check on your self configured page file by using one of the following commands:
wmic.exe pagefileset
or
wmic.exe pagefileset list /format:list
This will return the values for description, initial size, maximum size, name and SettingID.
Note:
You can not see the amount of page file in use. You can use the Task Manager for this purpose. Open it by running taskmgr.exe or pressing CTRL + Shift + ESC.
Setting your page file
When you want to configure your page file yourself you need to first disable the automatic configuration. After that you can create your own page file. Here's a little Step by Step:
- Disable the automatic configuration of the Windows page file:
wmic.exe computersystem where name=”%computername%” set AutomaticManagedPagefile=False
Note:
This command deletes all page file settings and sets the value for your pagefile to zero bytes.
- Specify your page file settings:
wmic.exe pagefileset where name=”C:\\pagefile.sys” set InitialSize=PageFileSize,MaximumSize=PageFileSize
To manage your Page File according to best practices I recommend using equal PageFileSize values for InitialSize and MaximumSize. Values for PageFileSize are measured in MegaBytes. (MB's)
- Reboot
Changing page file location
Another management option is to move the page file to another partition (or volume). Moving a page file involves deleting an existing page file and making a new one somewhere else. I used the following set of commands to move the Page File from the C: drive to the D: drive on my test system.
diskpart.exe
DISKPART> select disk 0
DISKPART> select partition 1
DISKPART> shrink desired=2280
DISKPART> create partition primary
DISKPART> select partition 2
DISKPART> format fs=ntfs label="Swap"
DISKPART> assign letter=E
DISKPART> exit
wmic.exe pagefileset create name="E:\pagefile.sys"
wmic.exe pagefileset where name="E:\\pagefile.sys" set InitialSize=2048,MaximumSize=2048
wmic.exe pagefileset where name="C:\\pagefile.sys" delete
You can replace values to suit your situation. Your settings will take effect after a reboot of the system.
Reverting back to the automatic page file
If you feel Windows is better than you in managing the page file you can revert back to the automatically configured page file by typing the following command:
wmic.exe computersystem where name=”%computername%” set AutomaticManagedPagefile=True
Reboot after typing the command.
Checking the registry
Of course the registry contains information on the page file. Within the registry you can view the location, the minimum size, the maximum size and loads of other information like the PagefileOnOSVolume registry key in the following location:
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
Using the registry to look at (and change) page file settings is version independent. You can use it on pre-Beta 3 and post-Beta 3 installations of Windows Server 2008.
Concluding
Page file management was changed in Server Core since Beta 3.
In early versions of Windows Server Codename "Longhorn" you could use the SCregEdit.wsf script to change page file settings, but this command wasn't very strong. The /PF command switch was deprecated.
You can still use the Windows Management Instrumentation Console (wmic.exe) to change many of your page file settings after you disable the AutomaticManagedPagefile setting.
You can also use the registry to change your page file settings, but this is a very error prone scenario. Using the Windows Management Instrumentation Console (wmic.exe) seems to be the easiest way, unless you want to change fancy settings.
Further reading
Optimizing Your Paging File (PAGEFILE.SYS)
How to use the 4GT RAM Tuning feature
How to verify the Page File location using a script
How to overcome the 4,095 MB paging file size limit in Windows
Definitions for system volume and boot volume
How to Move the Windows Default Paging File and Print Spooler to a Different Hard Disk
Windows Server 2008 System Requirements
How to verify the Page File location through a script
Server Core Tips and Tricks Vol. 4
Server Core – first steps
What's going on with my Pagefile?
Windows Server 2008 Step-by-Step Guides
How can I optimize the Windows 2000/XP/2003 virtual memory (Pagefile)?
Tuning Windows Server 2003
BitLocker Drive Encryption (BDE) enables the PagefileOnOSVolume registry setting
Disclaimer Beta Software
The information on this webpage applies to software from Microsoft that was in testing phase but utilizable by experienced users by the time the webpage was written. This software has not been released for sale, distribution or usage for the general public. The information on this webpage and the beta software are provided "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose.
Login