crabbox-hyperv-windows
Prepare a private copy of a generalized Windows Gen2 VHDX with a known local administrator and optional OOBE priming for local Crabbox Hyper-V. Not for ISO conversion, cloud/Linux, repository test execution, or package deployment.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 5
- Forks
- 12
01 前言 Front Matter
- name
- crabbox-hyperv-windows
- license
- MIT
- description
- Prepare a private copy of a generalized Windows Gen2 VHDX with a known local administrator and optional OOBE priming for local Crabbox Hyper-V. Not for ISO conversion, cloud/Linux, repository test execution, or package deployment.
02 资源文件 3
03 SKILL.md 正文
Prepare a local Windows Crabbox template
Consume a user-owned Gen2/UEFI Windows VHDX and create a new private copy. Never edit a stable parent image already used by leases. If the user has only an ISO, use windows-iso-to-vhdx first; it also owns public ISO download guidance.
Operating contract
| Concern | Contract |
|---|---|
| Use when | Preparing a Windows VHDX copy with a known local administrator and OOBE readiness for the Crabbox hyperv provider. |
| Do not use when | ISO conversion belongs to windows-iso-to-vhdx; running this repository's configured jobs belongs to crabbox. No Linux/cloud, hydration, package install, or host account changes. |
| Required inputs | Detached standalone generalized GPT Windows VHDX, new private output directory, verified Crabbox executable, Hyper-V switch, and securely supplied administrator password. |
| Mutation boundary | Inspect/WhatIf first. Actual copy/mount/account injection and optional priming VM require explicit task authority and an elevated PowerShell terminal. Never log credentials, modify the source/template/other VMs, or create a SYSTEM task. |
| Done when | Distinguish injected-only from primed: IMAGE_STATE_COMPLETE, administrator PowerShell Direct login, graceful shutdown, exact temporary-VM cleanup, detached output, and unchanged source are required for primed success. |
Inspect and pin
Use Windows with Hyper-V, Storage tools, PowerShell 7, and a switch the user has selected. Offline mounting requires Run as administrator; normal Crabbox execution runs as the invoking user with Hyper-V permissions. Desktop operations require an interactive guest session, not a LocalSystem host process. Do not create unattended SYSTEM tasks to hide failures.
Resolve the exact available binary before elevation, verify --version,
providers --json, and its SHA-256, and check its public release provenance.
Do not download or silently substitute another binary. The public contract
was verified with published v0.81.0; check version-specific
Hyper-V docs
before using a different version.
This helper expects a generalized installation that will process the
oobeSystem answer file on first boot. An already-specialized disk will not
replay OOBE; do not report an injected file as a working account. Use the
existing valid account/template instead, or start with suitable installation
media. It refuses to overwrite an existing answer file.
Prepare the private copy
Copy/hash, first boot and readiness are separate phases; they can be quiet. The timing reference distinguishes measured native lease/warm checks from the 38m 47s nested qualification with extra security cases. Individual copy/OOBE durations were not retained. The default 25-minute readiness budget starts after VM start; it is not a template-command estimate or total limit. Do not reboot or retry an active owner just because no output appears.
Run the template helper
from the repository root, first with -WhatIf:
& .\.agents\skills\crabbox-hyperv-windows\scripts\Initialize-CrabboxHypervWindowsTemplate.ps1 `
-VhdxPath $sourceVhdx -OutputDirectory $newPrivateDirectory `
-CrabboxPath $crabboxPath -Switch $switchName -WhatIf
For an explicitly requested operation, prompt locally—never in chat or as a plaintext command argument—and pass the secure object:
$guestPassword = Read-Host 'Template administrator password (retain securely)' -AsSecureString
& .\.agents\skills\crabbox-hyperv-windows\scripts\Initialize-CrabboxHypervWindowsTemplate.ps1 `
-VhdxPath $sourceVhdx -OutputDirectory $newPrivateDirectory `
-CrabboxPath $crabboxPath -Switch $switchName `
-AdminPassword $guestPassword -Prime
The new output directory, copied VHDX, and mounted answer file each have a verified private ACL for their creator, Administrators and SYSTEM. The answer file is created with that ACL atomically and checked through its open handle before credential bytes are written; directory protection alone is insufficient once the disk is mounted. A strong password is required; none is generated, returned or printed. The helper functions create the public Windows Setup local-account answer file and bound readiness probes. The module owns copy/mount/VM lifecycle checks. Unattend password encoding is reversible obfuscation, not encryption. Windows Setup may retain credential-bearing material in the image. Keep the whole image private, never upload it as proof, and retain the password through the user's secret manager. Local administrators can access the template. The helper does not persist a host credential file or environment variable.
-Prime creates exactly one task-owned Gen2 VM, uses normal Secure Boot and
vTPM configuration, and waits for authenticated administrator access plus
IMAGE_STATE_COMPLETE. It does not bypass Windows hardware/licensing checks.
OOBE may require the user to accept terms or resolve UI prompts; a timeout
leaves an explicitly unqualified output, never a success-shaped fallback.
No sleep duration alone proves readiness.
The source is copied, not mounted or modified. On completion the source hash is rechecked. The temporary VM is removed by its exact ID while the private copy remains. Failed priming may force off only that owned VM; do not treat the retained image as qualified. Inspect recovery diagnostics before retrying, and choose a new output directory; do not overwrite partial state.
Use the template separately
Keep the primed VHDX immutable while Crabbox leases use it as their
differencing-disk parent. Set the supported machine-local image/user/switch
settings outside Git. Supply CRABBOX_HYPERV_GUEST_PASSWORD only in the
invoking process from secure input; clear/restore it in finally. Environment
variables contain plaintext in process memory and are visible to privileged
processes; never echo or persist the value.
Crabbox owns per-lease verified OpenSSH/key bootstrap and Node/npm baseline.
Do not add FirstLogonCommands OpenSSH installations or features-on-demand
workarounds to the template. Desktop is separately requested with --desktop;
acquisition must verify an active guest user/Explorer session. It does not
qualify repository PowerShell/.NET toolchains. Normal native Windows
single-regular-file SFTP copy
is supported, not recursive directory/archive cp.
Use the local Windows guide and
crabbox project skill for separately authorized jobs, exact-ID lease cleanup,
and proof. A primed template is not configured-job proof; Node smoke is not
.NET/quality proof, and a high Windows build number is not IsolationSession
eligibility.
Sources and freshness
Reviewed 2026-11-04 against the public v0.81.0 provider contract and Windows LocalAccount password schema. Refresh the actual release/docs/help before assuming newer bootstrap, desktop, or file-copy support. No private services, host-specific paths, credentials, or preselected image builds are required.
04 同仓库更多 Skills
Windows界面登录与文件交接
windows-agent-handoff
在隔离的 Windows agent 会话中处理面向用户的 GUI、登录和文件交接;而非普通的无头(headless)工作。
技术文档撰写与审查
technical-documentation
撰写、审查或审计本仓库的技术文档,包括 README.md、CONTRIBUTING.md、根目录及局部范围的 AGENTS.md 文件、文档页面和文档漂移。适用于基于源码的文档撰写、行为验证和跨界面一致性检查。不要用于代码审查、deslop 差异清理,或由 docs-refactor 处理的整页重写、拆分与重组。
技术文档页面重构
docs-refactor
重构本仓库中的整个文档页面,同时不丢失经过源码核实的行为事实。适用于页面重写、拆分、重组,或对 README 章节、文档页面和说明文件进行大幅精简。不要用于常规文档撰写、针对性修正或文档审查;这些应使用 technical-documentation。
AI生成代码冗余清理
deslop
在代码审查前,对当前分支上 AI 生成的冗余代码进行限定于差异范围、行为中立的清理。用于从分支差异中移除无关紧要的注释、防御性检查、类型伪装、冗余中间变量、兼容性垫片或局部风格漂移。不要用于完整的安全性或正确性审查、由 technical-documentation 或 docs-refactor 处理的文档工作,或全仓库范围的重构。
windows-iso-to-vhdx
Create a new offline Windows Gen2/UEFI VHDX from a user-provided installation ISO, or guide a public Windows ISO download. Not for Crabbox account/OOBE preparation, existing disk maintenance, host installation, or Linux images.
crabbox
Run this repository's configured Windows Hyper-V Crabbox jobs, preview their sync scope, reuse or release an owned lease, and report validation evidence. Use for disposable local Windows checks and same-lease iteration. Not for preparing VHDX templates, cloud providers, Actions hydration, or package production.