rem # https://docs.microsoft.com/zh-tw/windows-hardware/manufacture/desktop/configure-uefigpt-based-hard-drive-partitions rem # https://learn.microsoft.com/zh-tw/windows-hardware/manufacture/desktop/oem-deployment-of-windows-desktop-editions-sample-scripts?view=windows-11&preserve-view=true#-createpartitions-uefitxt rem == 2024-12-18 02:48:04 rem << DiskPart /s B:\CreatePartitions-UEFI_AnyDiskSize.txt >> rem == CreatePartitions-UEFI.txt == rem == These commands are used with DiskPart to rem create four partitions rem for a UEFI/GPT-based PC. rem Adjust the partition sizes to fill the drive rem as necessary. == select disk 0 clean convert gpt rem == 1. Microsoft Reserved (MSR) partition ======= rem ---- For Windows 11 ---- rem # select partition 1 rem # delete partition override rem ---- For Windows 10 ---- rem #- create partition efi size=100 rem ** NOTE: For Advanced Format 4Kn drives, create partition msr size=16 rem == 2. System partition ========================= rem change this value to size = 260 ** create partition efi size=260 format quick fs=fat32 label="System" assign letter="S" NoErr rem #- rem #- == 2. Microsoft Reserved (MSR) partition ======= rem #- create partition msr size=16 rem == 3. Windows partition ======================== rem == a. Create the Windows partition ========== rem 975427584/1024/2=476283 MB create partition primary size=476283 rem == b. Create space for the recovery tools === rem ** Update this size to match the size of rem the recovery tools (winre.wim) rem plus some free space. rem #- shrink minimum=500 rem ==== shrink 32G+1G+2G=35G 1024*35=35840 MB rem shrink desired=35840 rem == c. Prepare the Windows partition ========= format quick fs=ntfs label="Windows" assign letter="W" NoErr rem == 4. Recovery partition ====================== rem #- create partition primary create partition primary size = 1024 format quick fs=ntfs label="Recovery" assign letter="R" NoErr set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" rem 0x8000000000000000 (prevent assigning drive letter automatically on new machines) default rem 0x8000000000000001 (set as required partition by system) rem ## gpt attributes=0x8000000000000001 rem ==== 5. Restore partition ====================== rem create partition primary size = 32768 rem 975431680/1024/2=476285 MB create partition primary size=476285 format quick fs=ntfs label="Data" assign letter="U" NoErr create partition primary format quick fs=ntfs label="Restore" shrink desired=2048 assign letter="T" NoErr rem ==== 6. Windows_PE partition ====================== create partition primary size = 2048 format quick fs=fat32 label="Windows_PE" assign letter="P" NoErr list volume list partition exit