When using NTLite to create a System Drive's new disk layout, it may cause a major problem by assigning the Recovery partition in sequential order, before the Windows partition. This becomes an issue if Windows Update runs out of disk space, while applying the Monthly Update to WinRE.
The normal practice for installing Windows is to create a standard UEFI-based disk layout:

You have two options with WinPE Setup:
NTLite can perform both options, but most users choose the second option. Setup has a design flaw where you can only use a disk layout to extend one disk partition (normally Windows) to the disk's end, but unblocked by any other partition.
By not assigning Recovery to the end makes it more difficult to expand the partition, in case more disk space is required. A 3rd-party disk partitioning tool is required to fix this problem if the Recovery partition unexpectedly runs out of space.
When Setup finds a disk with no partitions, it creates a new layout which extends Windows to the end of the disk, before shrinking it to allow Recovery to follow Windows.
You may have seen Windows install guides which instruct you to create a list of WinPE-based RunSynchronous commands to duplicate Setup's behavior by first extending Windows partition, and then shrinking it.
This solution immediately creates two more problems:
I wrote a PowerShell script which takes of the problem by importing any unattended file and safely inserting the diskpart commands as needed. This script works on the XML level, so it will leave everything unrelated to the WinPE pass untouched.
Run the script against your unattended file:
If you provide a filename that doesn't exist, a new barebones file will be created for you which will repartition the disk.
The script will delete any previous <DiskConfiguration> XML block, and insert the new RunSynchronous commands under <Order>1 and <Order>2. All existing WinPE pass commands will be shifted down by (<Order> + 2).
By default, the script creates an UEFI-based disk layout using the entire disk, except for a 800 MB Recovery partition at the end.
There are several command-line options:
Whenever you provide an existing file, a backup copy [filename].bak is always created.
How do I use the script? If you need to use NTLite's Unattended mode, allow NTLite to create the autounattend.xml.
When it's done, run the script on autounattend.xml to update it. There will be a backup file in the same folder, in case you need to revert. You can use this script on any unattended file created by another tool, or written/edited by yourself.
The normal practice for installing Windows is to create a standard UEFI-based disk layout:

You have two options with WinPE Setup:
- Create a disk layout, using fixed partition sizes (if known in advance), and which assign Recovery to the end.
- Create a disk layout, which works for any size disk, but assigns Recovery in front of Windows.
NTLite can perform both options, but most users choose the second option. Setup has a design flaw where you can only use a disk layout to extend one disk partition (normally Windows) to the disk's end, but unblocked by any other partition.
By not assigning Recovery to the end makes it more difficult to expand the partition, in case more disk space is required. A 3rd-party disk partitioning tool is required to fix this problem if the Recovery partition unexpectedly runs out of space.
When Setup finds a disk with no partitions, it creates a new layout which extends Windows to the end of the disk, before shrinking it to allow Recovery to follow Windows.
You may have seen Windows install guides which instruct you to create a list of WinPE-based RunSynchronous commands to duplicate Setup's behavior by first extending Windows partition, and then shrinking it.
Code:
cmd.exe /c echo select disk 0 >> X:\diskpartUEFI.txt
cmd.exe /c echo clean >> X:\diskpartUEFI.txt
cmd.exe /c echo convert gpt >> X:\diskpartUEFI.txt
cmd.exe /c echo create partition efi size=260 >> X:\diskpartUEFI.txt
cmd.exe /c echo format quick fs=fat32 label="System" >> X:\diskpartUEFI.txt
cmd.exe /c echo create partition msr size=128 >> X:\diskpartUEFI.txt
cmd.exe /c echo create partition primary >> X:\diskpartUEFI.txt
cmd.exe /c echo shrink desired=500 minimum=500 >> X:\diskpartUEFI.txt
cmd.exe /c echo format quick fs=ntfs label="Windows" >> X:\diskpartUEFI.txt
cmd.exe /c echo create partition primary >> X:\diskpartUEFI.txt
cmd.exe /c echo format quick fs=ntfs label="Recovery tools" >> X:\diskpartUEFI.txt
cmd.exe /c echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" >> X:\diskpartUEFI.txt
cmd.exe /c echo gpt attributes=0x8000000000000001 >> X:\diskpartUEFI.txt
cmd.exe /c echo exit >> X:\diskpartUEFI.txt
cmd.exe /c diskpart.exe /s X:\diskpartUEFI.txt
This solution immediately creates two more problems:
1. You need to insert a long list of RunSynchronousCommands into your unattended file.
2. If you have existing WinPE commands, they need to be shifted down and renumbered.
I wrote a PowerShell script which takes of the problem by importing any unattended file and safely inserting the diskpart commands as needed. This script works on the XML level, so it will leave everything unrelated to the WinPE pass untouched.
Run the script against your unattended file:
Code:
.\Resize_Recovery.ps1 .\autounattend.xml
Updating file: ".\autounattend.xml" -> UEFI, Recovery 800 MB
If you provide a filename that doesn't exist, a new barebones file will be created for you which will repartition the disk.
Code:
.\Resize_Recovery.ps1 unattend.xml
Creating new file: "unattend.xml" -> UEFI, Recovery 800 MB
The script will delete any previous <DiskConfiguration> XML block, and insert the new RunSynchronous commands under <Order>1 and <Order>2. All existing WinPE pass commands will be shifted down by (<Order> + 2).
By default, the script creates an UEFI-based disk layout using the entire disk, except for a 800 MB Recovery partition at the end.
There are several command-line options:
-UEFI | Change disk layout to UEFI standard (default mode) |
-MBR | Change disk layout to MBR standard |
-Disk # | Select a different disk number This is the disk number as reported by diskpart, after WinPE is booted. |
-Visible | Don't hide the CMD window running diskpart, if you want to see the script running |
filename | Name of the unattended file |
size | Size of Recovery partition in MB 800 MB is the recommended default, 250 MB is the minimum. |
Code:
.\Resize_Recovery.ps1 -MBR autounattend.xml 1024 -Visible
Updating file: "autounattend.xml" -> [visible] MBR, Recovery 1024 MB
.\Resize_Recovery.ps1 -UEFI autounattend.xml 760
Updating file: "autounattend.xml" -> UEFI, Recovery 760 M
Whenever you provide an existing file, a backup copy [filename].bak is always created.
How do I use the script? If you need to use NTLite's Unattended mode, allow NTLite to create the autounattend.xml.
When it's done, run the script on autounattend.xml to update it. There will be a backup file in the same folder, in case you need to revert. You can use this script on any unattended file created by another tool, or written/edited by yourself.