VirtualMemory: 'value out of range' error when sizes > 1/8th of the disk
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 32/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- powershell
- Lĩnh vực
- devops, operating-systems
Hướng nghiên cứu
Bắt đầu với điểm vào Set-PageFileSetting của tài nguyên VirtualMemory và tái hiện sự cố bằng cấu hình ổ đĩa D: 8 GB được cung cấp, với InitialSize 4096 và MaximumSize 7000. So sánh lỗi CIM với giải pháp thay thế dựa trên registry, bao gồm việc giữ lại các mục PagingFiles hiện có. Hoàn tất khi các thiết lập tệp phân trang hợp lệ lớn hơn một phần tám dung lượng đĩa được áp dụng mà không làm mất các thiết lập trên những ổ đĩa khác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- PowerShell
- Star
- 338
- Fork
- 80
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dsccommunity/ComputerManagementDsc
-
chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
chore
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
-
chore
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 64/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của dsccommunity/ComputerManagementDsc
Issue tương tự
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
microsoft/ebpf-for-windows#5604 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Theme: Bots Type: Bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
internetarchive/openlibrary#13743 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
blinklabs-io/actions#138 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
.Needs Triage .Run Repro Bot Priority:P2 Type:Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
metabase/metabase#83153 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày