Forum Discussion
AxelGlzs31
Jan 29, 2025Copper Contributor
AVD image - No paging file ?
Hello, While optimizing my template for AVD, I noticed that the Virtual Memory settings were configured to ‘No Paging File.’ I was wondering if this is expected behavior? Do you have any recommendat...
- Feb 20, 2025
For those coming across this post, I used a PowerShell script executed via ‘Custom configuration script’ during the creation of machines in the pool. This is the only way I found to keep the paging file enabled.
URL script HERE
aasimtek
Feb 03, 2025Copper Contributor
When optimizing your Azure Virtual Desktop (AVD) image, noticing that the Virtual Memory settings are configured to "No Paging File" can be a bit surprising, especially if you're used to seeing a paging file (pagefile.sys) on traditional physical or virtual machines. Here’s some context and recommendations regarding this setting:
Context
Azure Infrastructure:
Azure VMs, including those used for AVD, typically use managed disks that are highly performant and reliable. Azure’s infrastructure is designed to handle memory-intensive workloads efficiently.
Azure VMs often use temporary storage (D: drive) for paging files, which is SSD-based and provides good performance.
Windows 10 Multi-Session:
Windows 10 Multi-Session is optimized for multi-user environments, and certain default settings might differ from the standard Windows 10 installation to better suit virtual desktop scenarios.
Recommendations
Evaluate Workloads:
Memory-Intensive Applications: If your AVD users run memory-intensive applications, having a paging file can help prevent out-of-memory errors by offloading some data from RAM to disk.
General Use: For general use cases, the default "No Paging File" setting might be sufficient, especially if your VMs have adequate RAM.
Monitor Performance:
Performance Metrics: Monitor the performance of your AVD environment, particularly memory usage and page faults. Tools like Azure Monitor and Windows Performance Monitor can provide insights.
User Feedback: Gather feedback from users regarding performance. If users experience slowdowns or crashes, it might indicate that a paging file is needed.
Configure Paging File if Necessary:
System Managed Size: If you decide to enable the paging file, setting it to "System managed size" is often a good choice. This allows Windows to dynamically manage the paging file size based on system requirements.
Custom Size: Alternatively, you can set a custom size. A common recommendation is to set the initial size to 1.5 times the amount of RAM and the maximum size to 3 times the amount of RAM.
Steps to Configure Paging File
Open System Properties:
Right-click on "This PC" or "Computer" on the desktop or in File Explorer.
Select "Properties."
Click on "Advanced system settings" on the left side.
Performance Options:
In the System Properties window, under the "Advanced" tab, click on "Settings" in the Performance section.
Virtual Memory:
In the Performance Options window, go to the "Advanced" tab.
Click on "Change" in the Virtual memory section.
Configure Paging File:
Uncheck "Automatically manage paging file size for all drives."
Select the drive (usually C: or D:).
Choose "System managed size" or set a custom size.
Click "Set" and then "OK."
Restart the VM:
Restart the VM to apply the changes.
Conclusion
While the "No Paging File" setting might be the default for your AVD template, it’s essential to evaluate your specific workloads and performance needs. Monitoring and user feedback will guide you in deciding whether to enable and configure a paging file. If you do enable it, starting with a system-managed size is a prudent approach. Always test changes in a non-production environment before rolling them out broadly.
AxelGlzs31
Feb 03, 2025Copper Contributor
Hello,
Thank you for your response. I have already enabled the paging file on the C drive in automatic mode, but after running sysprep, capturing my image, and deploying new machines in the pool, the paging file configuration is not retained, and my virtual desktops end up without a paging file. I would like this setting to persist after sysprep. Any idea how to achieve this?
- aasimtekFeb 03, 2025Copper Contributor
When using Azure Virtual Desktop (AVD) or any virtual desktop environment, the paging file (pagefile.sys) configuration is often lost after running sysprep and deploying new machines. This happens because sysprep generalizes the system, resetting certain configurations, including the paging file settings. To ensure the paging file configuration persists after sysprep, you need to configure it in a way that survives the sysprep process.
Here’s how you can achieve this:
Solution: Configure the Paging File via a Custom Script or Unattend.xml
Option 1: Use an Unattend.xml File
The unattend.xml file is an answer file used during the Windows setup process to automate configurations. You can configure the paging file settings in this file so that they are applied after sysprep.
- Create or Modify the Unattend.xml File:
- If you don’t already have an unattend.xml file, create one.
- Add the following section to configure the paging file:
- xml<settings pass="specialize"> <component name="Microsoft-Windows-SystemRestore-Main" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <DisableSR>0</DisableSR> </component> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <PageFile> <Size>2048</Size> <Path>%SystemDrive%\pagefile.sys</Path> </PageFile> </component> </settings>Run HTML
- Copy
- Adjust the <Size> value to your desired paging file size (in MB). Use 0 for system-managed size.
- Place the Unattend.xml File in the Correct Location:
- Save the unattend.xml file in the %WINDIR%\System32\Sysprep directory on your image.
- Run Sysprep with the Unattend.xml File:
- When running sysprep, specify the unattend.xml file using the /unattend flag:
- cmdsysprep /generalize /oobe /shutdown /unattend:unattend.xml
- Copy
- Capture and Deploy the Image:
- Capture the image and deploy it to your AVD pool. The paging file configuration should now persist.
Option 2: Use a Post-Deployment Script
If you prefer not to use an unattend.xml file, you can configure the paging file via a script that runs after deployment.
- Create a PowerShell Script:
- Create a PowerShell script to configure the paging file. For example:
- powershell$pageFileSetting = Get-WmiObject -Query "SELECT * FROM Win32_PageFileSetting WHERE Name='C:\\pagefile.sys'" if (-not $pageFileSetting) { $pageFileSetting = Set-WmiInstance -Class Win32_PageFileSetting -Arguments @{Name="C:\\pagefile.sys"; InitialSize=2048; MaximumSize=4096} } else { $pageFileSetting.InitialSize = 2048 $pageFileSetting.MaximumSize = 4096 $pageFileSetting.Put() }
- Copy
- Adjust the InitialSize and MaximumSize values as needed.
- Run the Script During Deployment:
- Add the script to your deployment process so it runs after the virtual machines are provisioned. For example:
- Use Azure VM extensions to run the script.
- Include the script in your AVD host pool setup process.
- Add the script to your deployment process so it runs after the virtual machines are provisioned. For example:
Option 3: Configure via Group Policy (GPO)
If you are managing AVD with Active Directory or Azure AD, you can use Group Policy to enforce the paging file configuration.
- Create a GPO:
- Open the Group Policy Management Console (GPMC).
- Create a new GPO and link it to the appropriate Organizational Unit (OU) containing your AVD machines.
- Configure the Paging File Setting:
- Navigate to:
- CopyComputer Configuration > Administrative Templates > System > Memory Management
- Enable the policy "Configure paging file size" and specify the desired size.
- Apply the GPO:
- Ensure the GPO is applied to your AVD machines. The paging file configuration will be enforced after the machines boot up.
Why This Happens
- Sysprep resets system configurations, including the paging file settings, to ensure a clean state for deployment.
- The paging file configuration is stored in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management. Sysprep does not retain these settings by default.
Best Practices
- Test your solution in a non-production environment before deploying it to your AVD pool.
- Use the unattend.xml method if you want the paging file configuration to be applied during the initial setup.
- Use a post-deployment script or GPO if you need more flexibility or want to manage the configuration dynamically.
By following one of these methods, you can ensure that the paging file configuration persists after sysprep and is applied to your AVD machines.
- AxelGlzs31Feb 04, 2025Copper Contributor
Thank you, but ChatGPT gave me the answers as well. I would have preferred someone with real hands-on experience.
- Create or Modify the Unattend.xml File: