From 23c539dbe2eed233d4ebfe78c49ff5c0ba94fc13 Mon Sep 17 00:00:00 2001 From: Git Sagar Date: Thu, 10 Sep 2026 05:11:40 -0300 Subject: [PATCH] generalize: lay the data disk out in Audit Mode, not only in specialize Formatting it from a specialize RunSynchronousCommand is not enough on its own. FolderLocations is applied by Shell-Setup while the disk is prepared by Deployment, and component order within a pass is not guaranteed -- so the relocation can be evaluated before the volume it names exists, which fails silently and leaves profiles on C:. That is what a correctly formatted data disk carrying nothing but NTFS metadata was telling us. Audit Mode is a fully booted OS with the disk already attached, so doing it before sysprep makes the volume unconditionally present by the time any pass looks for it. The specialize copy stays, now purely to re-assert the drive letter after generalize clears MountedDevices. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_0117qMyjpuXsjpVAcpJbFD8g --- lib/images/windows/templates/generalize.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/images/windows/templates/generalize.nix b/lib/images/windows/templates/generalize.nix index 3e43a93..3b4d3fe 100644 --- a/lib/images/windows/templates/generalize.nix +++ b/lib/images/windows/templates/generalize.nix @@ -336,6 +336,17 @@ in { del /q C:\Windows\Panther\unattend.xml 2>nul del /q C:\Windows\Panther\Unattend\unattend.xml 2>nul del /q C:\Windows\System32\Sysprep\Panther\unattend.xml 2>nul + ${lib.optionalString (dataDisk != null) '' + :: Lay the data disk out here, in Audit Mode, rather than leaving it to the + :: specialize pass alone. Component order within a pass is not guaranteed, + :: and FolderLocations is applied by Shell-Setup while the disk is prepared + :: by Deployment -- so relocation can be evaluated before the volume it + :: names exists, which silently leaves profiles on C:. Audit Mode is a + :: fully booted OS with the disk already attached, so this always works. + :: The specialize copy stays as a letter re-assertion after generalize + :: clears MountedDevices. + call C:\vmix-init-data-disk.cmd + ''} C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe ${if delayOobeRun then "/shutdown" else "/reboot"} /quiet /unattend:C:\oobe-unattend.xml ''; }