vm-repair scripts: add read-only win-detect-nvme-readiness detection script - #144
Conversation
|
Late to this since it has already merged, but it is worth recording how it landed on my side — it I have adopted your Worth adding as a data point: on an Azure-hosted Windows machine I scored the old and new predicates Your validation notes caught two more. Both were real in my code, in a different form:
On the hive unload, your "Reliable hive unload" section describes exactly the failure Where the two disk helpers stand now. #143 has been restructured into three smaller PRs in They are not quite duplicates: If you would rather they converge properly, I am happy either way: fold One smaller thing: |
Merging upstream/main auto-resolved src/windows/common/helpers/README.md to upstream's copy, which dropped all eight helper rows from main. The three pull request branches were unaffected - each builds its own README from upstream and adds only its own rows - so this restores main to the union of the three, in dependency order. Also resolves the map.json conflict by keeping both sides: upstream's win-detect-nvme-readiness entry from Azure#144 alongside ours. Verified: 47 entries, no duplicate ids, no upstream id lost, and every entry path resolves to a file that exists.
Summary
Adds an NVMe-aware disk-discovery helper for Windows repair VMs, and the first script that uses it.
The existing helpers identify attached disks using the SCSI-specific model name
Microsoft Virtual Disk.On repair VMs using an NVMe controller this can return no disks, and dependent repair scripts may then
complete without modifying the attached OS disk while still reporting success. The new helper selects
eligible disks by
BusType, supporting SCSI, SAS, RAID and NVMe controllers.win-detect-nvme-readinessis a read-only detection script built on that helper. It reports whether aWindows OS disk can boot from an NVMe disk controller: the
stornvmeStartvalue,stornvme.syspresence, NVMe
CriticalDeviceDatabaseentries, the active ControlSet, and the bus types of attacheddisks. It writes an evidence bundle and emits one machine-readable line prefixed
[NVME-EVIDENCE-JSON]. It makes no changes: the SYSTEM hive is mounted, read and unmounted.Changes
src/windows/common/helpers/Get-Disk-Partitions-v3.ps1(Get-Disk-Partitions-v3,Get-Windows-OsDrives-v3).src/windows/win-detect-nvme-readiness.ps1.map.jsonrun-idwin-detect-nvme-readiness.Deliberately unchanged
Reliable hive unload
A
reg unloadissued straight after a registry read fails with "Access is denied" because the PowerShellregistry provider still holds keys open, leaving the hive mounted and locking the attached disk for later
runs. The detection script retries, verifies with
Test-Path HKLM:\<mount>, and logs the manual unloadcommand rather than suppressing the error.
Live-validated on SCSI and NVMe repair VMs. Two defects were found and fixed during that validation:
the helper returned its own log lines as data, and it returned before Windows had assigned drive
letters to a newly-onlined disk — which would have made the first run against every fresh repair VM
report "no Windows installation found".