OSD Partition Setup, Mike Terrill Edition (The Optimized Way).

Update 2022.09.29 – Summary of Partitions.  EFI needs to be larger to hold more firmware updates, and larger updates.

  • EFI: 496MB
  • MSR: 128MB
  • Windows (Primary): Remaining
  • Recovery: 984MB

If you download the Import at the end, adjust the EFI to match the new guidance.

Original Post below which explains how to set the Windows Partition to use the Remaining space while setting a fixed size after it.
——————–

I recently rebuilt my TS and due to my habit of pasting pictures and results on twitter, it gets scrutinized, mocked, and maybe at times even a bit of praise.  The nice thing is, I have hundreds of eyes looking it over and, lets just say, offering helpful suggestions.

In my new TS, I tried to implement a better Partitioning step than the default ConfigMgr provided partition step.  Not that anything is wrong with the default step, but it could be better.

Default:
image

image

Couple things to note, 500MB for EFI, you don’t need that much, what do you need?  Mike Terrill to the rescue:
image

Ok, so now I’ve changed that to 260MB.  But now I have a Recovery Partition that is 1% of the disk size, this can be bad for two reasons… too small or too big.  We had a discussion on Twitter about the size of the recovery partition, and the old recommendation is 499MB, but the new one is 984MB, as WinRE can grow over 500MB now…and something about VSS… bla bla.. ask David Segura.. @SeguraOSD

image

Ok, so if you have a 100GB drive or larger, then you’re just wasting part of your disk on that recovery partition, so why not force it to be a certain size.  Well, how do you do that?  Mike to the rescue again..

Mike explains how to do it in this blog post: https://miketerrill.net/2017/07/12/configuration-manager-osd-recovery-partitions-and-mbr2gpt/
However, he explains how to do it for the older MBR (BIOS) formatting, and not the GPT (UEFI) formatting.  But then recently he filled in the blanks on Twitter:
image

*Note, he posted this before our discussion about changing the Recovery Partition size from 499 to 984.

So now I have all of the info, time to put it all together.. this is how it looks:
Group Conditions, I copied the ones from the original “Partition Disk 0 – UEFI Steps to the group:
image
image
image
image

  1. Partition Disk 0 – UEFI
    image image
  2. Run Command Line: This step creates the diskpart file used to automate the partitioning process.  It’s basically copied identically from Mike’s Twitter post, but instead of creating a text file, and using a package, I use a trick I’ve used before to build scripts / files on the fly without requiring content.. echo >>
    cmd.exe /c echo select disk 0 >> %temp%\diskpartUEFI.txt && cmd.exe /c echo list partition >> %temp%\diskpartUEFI.txt && cmd.exe /c echo select partition 3 >> %temp%\diskpartUEFI.txt && cmd.exe /c echo shrink desired=986 minimum=986 >> %temp%\diskpartUEFI.txt && cmd.exe /c echo create partition primary >> %temp%\diskpartUEFI.txt && cmd.exe /c echo format quick fs=ntfs label=Recovery >> %temp%\diskpartUEFI.txt && cmd.exe /c echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" >> %temp%\diskpartUEFI.txt && cmd.exe /c echo gpt attributes=0x8000000000000001 >> %temp%\diskpartUEFI.txt && cmd.exe /c echo list partition >> %temp%\diskpartUEFI.txt && cmd.exe /c echo exit >> %temp%\diskpartUEFI.txt
  3. Run Command Line: This step calls diskpart and applies the txt file you created in the last step.
    diskpart.exe /s %temp%\DiskPartUEFI.txt

During the TS, what does this look like:
image

You’ll see your diskpartUEFI.txt file created in the temp folder, you’ll see the log show that it ran the diskpart process using your diskpartUEFI file. The smsts.log also shows the OS partition being shrunk and the Recovery Partition being created.  Then gives you a list of your 4 partitions, with the sizes you specified.

In Windows, you’ll only see the 3 partitions:
image

Now you know the optimized way to partition your drive and this is all documented in one place, so you don’t have to search twitter, which is like impossible to find that one tweet you were looking for.

Special Thanks to Mike Terrill, who came up with this entire process, and David Segura for the guidance on the EFI partition size.

Format OSD TS Group Steps - Mike Terrill Ed. - DOWNLOAD HERE (4568 downloads )

Posted on GARYTOWN.COM

18 thoughts on “OSD Partition Setup, Mike Terrill Edition (The Optimized Way).”

  1. Gary, if you’re interested, I just wrote a PS script that can do this without needing the Diskpart text files. You could probably even make it into a command line without needing a package. It also writes the diskpart output to both a log file and the console.

    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
    $LogPath = $tsenv.Value(“_SMSTSLogPath”)
    $UEFI = $tsenv.Value(“_SMSTSBootUEFI”)
    If ($UEFI -eq $TRUE){
    “select disk 0″,”list partition”,”select partition 3″,”shrink desired=984 minimum=984″,”create partition primary”,”format quick fs=ntfs label=Recovery”,”set id=`”de94bba4-06d1-4d40-a16a-bfd50179d6ac`””,”gpt attributes=0x8000000000000001″,”list partition” | diskpart | Tee-Object -FilePath “$LogPath\Create-RecoveryPartition.log”
    }
    else
    {
    “select disk 0″,”list partition”,”select partition 2″,”shrink desired=984 minimum=984″,”create partition primary”,”format quick fs=ntfs label=Recovery”,”set id=27″,”list partition” | diskpart | Tee-Object -FilePath “$LogPath\Create-RecoveryPartition.log”
    }

    Reply
  2. I changed the first part of the creation of diskpartUEFI.txt. I changed the ‘zero’ to %OSDDiskIndex% to cater for ‘not installing on drive 0’-situations (eg. Spindle is on 0 and SSD is 1). The line now starts with cmd.exe /c echo select disk %OSDDiskIndex% >> %temp%\diskpartUEFI.txt …..

    Reply
  3. Hi Gary,
    Any idea why the filesystem on the recovery partition isn’t showing up in diskmgmt? In diskpart it shows up correctly as NTFS but not on the disk in diskmgmt.

    Reply
    • I looked and looked and couldn’t find where I heard that. The only thing I can think of is that 496 is exactly dividable by 8, while 500 is not.

      Reply
  4. Hey Garry,
    Amazing work!!!
    I added this step in the imaging, I can see the Recovery partition is being created. However, after it downloads the OS.wim, applies and reboot initiated, the system fails to proceed and brings up the BSOD with “Stop Code: DRIVER PNP WATCHDOG” and it goes in the loop. It’s a VM, the VM drivers are being injected via TS step after Applying OS Image as well the drivers were injected into OS.wim via DISM offline as well to the single index. It’s a single index OS.wim file. If I remove these steps, it images fine. Going to adjust some steps and check.

    Reply
    • actually nvm, it’s causing trouble without those steps as well. I have a custom TS which does sysprep on top of a machine which was successfully imaged before.

      Reply
  5. Hi Gary, do you know offhand if this changed with Win 11 23H2? I disabled the original Partition Disk 0 – BIOS/UEFI steps that were part of the defaults from Microsoft, and added your steps to generate the UEFI text file and run it. When I run the task sequence, I can see it applies the disk part steps, but it then fails to apply the image with error 0x80070057.

    I can still access Diskpart in WinPE, and I can see that it applied all the partitions properly. I see the partition steps in SMSTS.log completed with exit code 0, but I get the following errors:
    Failed to save environment to (80070057)
    Failed to save the current environment block. Error (0x80070057)
    Failed to persist execution state. Error 0x(80070057)
    Failed to save execution state and environment to local hard disk

    If I go back and remove the DiskPart steps, and go back to the original format and partition steps included in the task sequence as defaults from Microsoft, the imaging process completes successfully, but since the recovery partition is set to use the last 1% of disk space, I get about a 2.2 GB partition on a 256 GB drive. If I manually set the recovery partition to 986 MB as mentioned above, I have ~1.2 GB unallocated space after the recovery partition, which isn’t ideal either. It’s weird.

    Reply
  6. How do you assign the OSDisk variable when partitioning the disk this way? I tried doing this. While it completes the partitioning and formatting, that variable was originally configured in the Microsoft format/partition step in the ts, which is now disabled, so the ts fails when trying to apply the image.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.