Partitions: Modifying MDT to Support Custom Partitioning


20150710 Updated script to allow a default of 984 MB but allows the BdeDriveSize Property to be set in CustomSettings.ini to override this.  Example:  BdeDriveSize = 800

So you are now aware that you may need to make some changes in MDT if you spent some time reading Partitions: My Recommendations for Windows Deployments.  Fortunately there is an easy solution.

Minor modifications to ZTIDiskpart.wsf allow for the Partition Sizes we want.  Here is the original block that will need to be modified

If bCreateBootPartition Then
	sBootDrive = GetLastAvailableDriveLetter
	bHasBootPartition = true
	If isuEFI then
		oLogging.CreateEntry "Create an uEFI/GPT Boot Partition set. "  & sBootDrive, LogTypeInfo
		oUtility.RunCommandWrite oExec, "CREATE PARTITION PRIMARY Size=" & cstr(WINRE_DRIVE_SIZE)
		oUtility.RunCommandWrite oExec, "FORMAT QUICK FS=NTFS LABEL=""Windows RE tools"""
		oUtility.RunCommandWrite oExec, "ASSIGN LETTER=" & left( GetLastAvailableDriveLetter, 1)
		oUtility.RunCommandWrite oExec, "set id=""de94bba4-06d1-4d40-a16a-bfd50179d6ac"""
		oUtility.RunCommandWrite oExec, "gpt attributes=0x8000000000000001"
		oUtility.RunCommandWrite oExec, "DETAIL PARTITION"
		oUtility.RunCommandWrite oExec, "DETAIL VOLUME"
		oUtility.RunCommandWrite oExec, "CREATE PARTITION EFI Size=" & cstr(iBdeDriveSize)
		oUtility.RunCommandWrite oExec, "FORMAT QUICK FS=Fat32 LABEL=""System"""
		oUtility.RunCommandWrite oExec, "ASSIGN LETTER=" & left( sBootDrive, 1)
		oUtility.RunCommandWrite oExec, "DETAIL PARTITION"
		oUtility.RunCommandWrite oExec, "DETAIL VOLUME"
		oUtility.RunCommandWrite oExec, "CREATE PARTITION MSR SIZE=128"
		oUtility.RunCommandWrite oExec, "DETAIL PARTITION"
		oUtility.RunCommandWrite oExec, "DETAIL VOLUME"
	Else
		oLogging.CreateEntry "Create a MBR Boot Partition set. "  & sBootDrive, LogTypeInfo
		oUtility.RunCommandWrite oExec, "CREATE PARTITION PRIMARY Size=" & cstr(iBdeDriveSize)
		oUtility.RunCommandWrite oExec, "FORMAT QUICK FS=NTFS LABEL=""System"""
		oUtility.RunCommandWrite oExec, "ASSIGN LETTER=" & left( sBootDrive, 1)
		' oUtility.RunCommandWrite oExec, "ATTRIBUTES VOLUME SET NODEFAULTDRIVELETTER NOERR"
		oUtility.RunCommandWrite oExec, "ACTIVE"
		oUtility.RunCommandWrite oExec, "DETAIL PARTITION"
		oUtility.RunCommandWrite oExec, "DETAIL VOLUME"
	End if
End if 


And here is the modified code

If isuEFI then
	oLogging.CreateEntry "Create an uEFI/GPT Boot Partition set. "  & sBootDrive, LogTypeInfo
	'-------------------------------------------------------------------------------------------------------------
	oLogging.CreateEntry "(Segura) Partition 1: Saving the drive letter used for Windows RE tools to Variable PartitionWinRELetter", LogTypeInfo
	oEnvironment.Item("PartitionWinRELetter") = left( GetLastAvailableDriveLetter, 1)
	
	oLogging.CreateEntry "(Segura) Partition 1: " & oEnvironment.Item("PartitionWinRELetter") & ": " & cstr(iBdeDriveSize) & " MB NTFS - Windows RE tools", LogTypeInfo
	oUtility.RunCommandWrite oExec, "CREATE PARTITION PRIMARY Size=" & cstr(iBdeDriveSize)
	oUtility.RunCommandWrite oExec, "FORMAT QUICK FS=NTFS LABEL=""Windows RE tools"""
	oUtility.RunCommandWrite oExec, "ASSIGN LETTER=" & oEnvironment.Item("PartitionWinRELetter")
	oUtility.RunCommandWrite oExec, "set id=""de94bba4-06d1-4d40-a16a-bfd50179d6ac"""
	oUtility.RunCommandWrite oExec, "gpt attributes=0x8000000000000001"
	oUtility.RunCommandWrite oExec, "DETAIL PARTITION"
	oUtility.RunCommandWrite oExec, "DETAIL VOLUME"
	'-------------------------------------------------------------------------------------------------------------
	oLogging.CreateEntry "(Segura) Partition 2: " & left( sBootDrive, 1) & ": 200 MB FAT32 - System", LogTypeInfo
	oUtility.RunCommandWrite oExec, "CREATE PARTITION EFI Size=200"
	oUtility.RunCommandWrite oExec, "FORMAT QUICK FS=Fat32 LABEL=""System"""
	oUtility.RunCommandWrite oExec, "ASSIGN LETTER=" & left( sBootDrive, 1)
	oUtility.RunCommandWrite oExec, "DETAIL PARTITION"
	oUtility.RunCommandWrite oExec, "DETAIL VOLUME"
	'-------------------------------------------------------------------------------------------------------------
	oLogging.CreateEntry "(Segura) Partition 3: 128 MB MSR", LogTypeInfo
	oUtility.RunCommandWrite oExec, "CREATE PARTITION MSR SIZE=128"
	oUtility.RunCommandWrite oExec, "DETAIL PARTITION"
	oUtility.RunCommandWrite oExec, "DETAIL VOLUME"
	'-------------------------------------------------------------------------------------------------------------
Else
	oLogging.CreateEntry "Create a MBR Boot Partition set. "  & sBootDrive, LogTypeInfo
	'-------------------------------------------------------------------------------------------------------------
	oLogging.CreateEntry "(Segura) Partition 1: Saving the drive letter used for System to Variable PartitionWinRELetter", LogTypeInfo
	oEnvironment.Item("PartitionWinRELetter") = left( sBootDrive, 1)
	
	oLogging.CreateEntry "(Segura) Partition 1: " & left( sBootDrive, 1) & ": " & cstr(iBdeDriveSize) & " MB NTFS - System", LogTypeInfo
	oUtility.RunCommandWrite oExec, "CREATE PARTITION PRIMARY Size=" & cstr(iBdeDriveSize)
	oUtility.RunCommandWrite oExec, "FORMAT QUICK FS=NTFS LABEL=""System"""
	oUtility.RunCommandWrite oExec, "ASSIGN LETTER=" & left( sBootDrive, 1)
	' oUtility.RunCommandWrite oExec, "ATTRIBUTES VOLUME SET NODEFAULTDRIVELETTER NOERR"
	oUtility.RunCommandWrite oExec, "ACTIVE"
	oUtility.RunCommandWrite oExec, "DETAIL PARTITION"
	oUtility.RunCommandWrite oExec, "DETAIL VOLUME"
	'-------------------------------------------------------------------------------------------------------------	
End if


The updated ZTIDiskpart will create a new Environment Variable (PartitionWinRELetter) so we know which drive letter is System (MBR) or WinRE (GPT).  This will be used in a future update for WinRE Configuration.

There are additional changes that are required in ZTIDiskpart and it is recommended pulling and comparing the files I have in Github.

Download Customized MDT ZTIDiskpart.wsf from GitHub

Remember to make a backup of your ZTIDiskpart.wsf before replacing

Advertisements