VirtualMemory: 'value out of range' error when sizes > 1/8th of the disk
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 32/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- powershell
研究方向
從 VirtualMemory 資源的 Set-PageFileSetting 進入點開始,使用提供的 8 GB D: 磁碟機設定(InitialSize 4096、MaximumSize 7000)重現問題。比較 CIM 失敗與以登錄為基礎的因應措施,包括保留現有的 PagingFiles 項目。完成標準是:能夠套用高於磁碟容量八分之一的有效分頁檔設定,同時不遺失其他磁碟機上的設定。
由索引模型根據 Issue 內容生成。
描述
Details of the scenario you tried and the problem that is occurring
I'm trying to utilize Azure VM temp disks for the pagefile but due to their small size (typically 2x RAM) and a limitation in Set-CimInstance (and similar methods), it's not possible to create anything of much use (e.g. only 1Gb on an 8Gb temp drive).
For example, splitting out the offending command in Set-PageFileSetting against an 8Gb drive with sufficient free space:
$Drive = 'D:'
$InitialSize = 4096
$MaximumSize = 7000
$setParams = @{
Namespace = 'root\cimv2'
Query = "Select * from Win32_PageFileSetting where SettingID='pagefile.sys @ $Drive'"
Property = @{
InitialSize = $InitialSize
MaximumSize = $MaximumSize
}
}
Set-CimInstance @setParams
Throws the following error:
Verbose logs showing the problem
Set-CimInstance : Value out of range
At line:1 char:5
+ Set-CimInstance @setParams
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Win32_PageFileS...\pagefile.sys"):CimInstance) [Set-CimInstance], CimException
+ FullyQualifiedErrorId : HRESULT 0x8004102b,Microsoft.Management.Infrastructure.CimCmdlets.SetCimInstanceCommand
Suggested solution to the issue
All the CIM-based solutions seem to have a base class that is the underlying issue. To work around it, the only solution I've found is to directly set the registry key:
<#
.SYNOPSIS
Sets a new page file name.
.PARAMETER Drive
The letter of the drive containing the page file
to change the settings of.
.PARAMETER InitialSize
The initial size to set the page file to.
.PARAMETER MaximumSize
The maximum size to set the page file to.
#>
function Set-PageFileSetting
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[System.String]
$Drive,
[Parameter()]
[System.Int64]
$InitialSize = 0,
[Parameter()]
[System.Int64]
$MaximumSize = 0
)
# Using Set-CimInstance fails if pagefile exceeds 1/8th of the available disk space so we're switching to using direct registry key settings.
$pageFileName = Join-Path `
-Path $driveInfo.Name `
-ChildPath 'pagefile.sys'
$value = "$pageFileName $InitialSize $MaximumSize`n" # Even though it's a Reg_SZ_Multi, it's not double-null terminated
# TODO: Fix to support other drive values
Set-ItemProperty `
-LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management' `
-Name 'PagingFiles' `
-Type MultiString `
-Value $value `
-Force
}
Write-Verbose -Message ($script:localizedData.SettingPageFileSettingsMessage -f $Drive, $InitialSize, $MaximumSize)
}
The above is incomplete as it does not account for any other / pre-existing settings on another drive but that shouldn't be too hard to work out given the simple data structure of the registry key.
The DSC configuration that is used to reproduce the issue (as detailed as possible)
Using a system with a D: drive that is 8Gb in size:
VirtualMemory "pagefile"
{
Type = 'CustomSize'
Drive = 'D'
InitialSize = 4096
MaximumSize = 7000
}
The operating system the target node is running
OsName : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Version and build of PowerShell the target node is running
Name Value
---- -----
PSVersion 5.1.17763.1971
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.1971
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Version of the DSC module that was used ('dev' if using current dev branch)
8.4.0
- 主要語言
- PowerShell
- 星號
- 338
- 分支
- 80
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
dsccommunity/ComputerManagementDsc 的其他 Issue
-
chore
難度 2/5 1-3 小時 新手友好度 78/100
-
chore
難度 4/5 3-5 天 新手友好度 68/100
-
chore
難度 4/5 3-5 天 新手友好度 64/100
-
難度 2/5 1-3 小時 新手友好度 55/100
-
難度 4/5 3-5 天 新手友好度 35/100
查看 dsccommunity/ComputerManagementDsc 的全部 Issue
相似的 Issue
-
[quality] refresh-radar-reports.yml runs on ubuntu-latest while every other job pins ubuntu-24.04未關閉agent/quality hive/hosted-available-lke648397-260827-5n31 quality testing
難度 1/5 1-3 小時 新手友好度 90/100
維護者通常 1 天內回覆
-
CI enhancement
難度 2/5 1-3 小時 新手友好度 84/100
OpenZeppelin/compact-contracts#1048 ·
維護者通常 1 天內回覆
-
cvss-severity:high devguard l3montree-cybersecurity/.../devguard-documentation pkg:oci/devguard-documen...ch=amd64&tag=main-amd64 risk:low state:open
難度 2/5 1-3 小時 新手友好度 70/100
l3montree-dev/devguard-documentation#315 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 88/100
cloudnative-pg/charts#1040 ·
維護者通常 1 天內回覆
-
good first issue hacktoberfest
難度 2/5 1-3 小時 新手友好度 92/100
elnachto/laya-triage#2 ·