How can I support multiple partition layouts with the same Win11 OS image? Does NTLite support this? If not, can this be done with a custom post-setup script?
There's several ways to approach this problem, but you have two big challenges:
- This can't be done using a normal unattended disk layout, because you need some scripting help.
- W11 is different that it really, really wants to have a Recovery partition. I presume you're supporting production users, so not having a working WinRE isn't a negotiable option.
The problem is W11 prefers having the Recovery partition follow the Windows volume, but you're creating a sandwich where the partition layout looks like:
EFI | MSR | Windows | Recovery | E | F* | G*
What you can do is manually create an autounattend.xml (or modify the one NTLite creates, after it's done building the ISO), and run a CMD script in the WinPE pass. This script would run WMIC to discover the Dell model name, and select one of the pre-defined partition layouts.
diskpart would be executed to create all the desired partitions, and at the script's end execution returns back to WinPE Setup.
1. Create a script something like this (untested):
Code:
@echo off
setlocal
:: Get the computer model using WMIC
for /f "tokens=2 delims==" %%a in ('wmic computersystem get model /value') do set "PCMODEL=%%a"
:: Remove trailing spaces from the model string
if defined PCMODEL set "PCMODEL=%PCMODEL:~0,-1%"
echo Detected PC Model: [%PCMODEL%]
:: Branch based on model name (case-insensitive)
if /i "%PCMODEL%"=="Latitude 5520" goto MODEL_A
if /i "%PCMODEL%"=="ThinkPad T14" goto MODEL_B
goto DEFAULT_LAYOUT
:MODEL_A
echo Applying custom layout for Model A...
(echo select disk 0
echo clean
echo convert gpt
echo create partition efi size=260
echo format quick fs=fat32 label="System"
echo create partition msr size=16
echo create partition primary size=[SOME BIG NUMBER]
echo format quick fs=ntfs label="Windows"
echo create partition primary size=900
echo format quick fs=ntfs label="Recovery"
echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
echo gpt attributes=0x8000000000000001
echo create partition primary size=500
echo format quick fs=ntfs
echo exit) | diskpart
goto FINISH
:MODEL_B
echo Applying custom layout for Model B...
(echo select disk 0
echo clean
echo convert gpt
echo create partition efi size=260
echo format quick fs=fat32 label="System"
echo create partition msr size=16
echo create partition primary size=[SOME BIG NUMBER]
echo format quick fs=ntfs label="Windows"
echo create partition primary size=900
echo format quick fs=ntfs label="Recovery"
echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
echo gpt attributes=0x8000000000000001
echo create partition primary size=500
echo format quick fs=ntfs
echo create partition primary size=500
echo format quick fs=ntfs
echo exit) | diskpart
goto FINISH
:DEFAULT_LAYOUT
echo Applying default partition layout...
(echo select disk 0
echo clean
echo convert gpt
echo create partition efi size=260
echo format quick fs=fat32 label="System"
echo create partition msr size=16
echo create partition primary size=[SOME BIG NUMBER]
echo format quick fs=ntfs label="Windows"
echo create partition primary size=900
echo format quick fs=ntfs label="Recovery"
echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
echo gpt attributes=0x8000000000000001
echo create partition primary size=500
echo format quick fs=ntfs
echo create partition primary size=500
echo format quick fs=ntfs
echo create partition primary size=500
echo format quick fs=ntfs
echo exit) | diskpart
goto FINISH
2. Mount the boot.wim in NTLite. Copy this script file to somewhere. The root folder is fine.
3. From the unattended file, call this script. WinPE is mounted in a RAM disk under X:
Code:
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Order>1</Order>
<Path>cmd /c X:\scriptname.cmd</Path>
</RunSynchronousCommand>
</RunSynchronous>
<ImageInstall>
<OSImage>
<WillShowUI>OnError</WillShowUI>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>3</PartitionID>
</InstallTo>
</OSImage>
</ImageInstall>
<UserData>
<ProductKey>
<Key></Key>
</ProductKey>
</UserData>
</component>
</settings>
4. In Post-Setup, you can run another script to assign drive letters to the data partitions.