0 ratings0% found this document useful (0 votes) 187 views19 pagesDiskpart Script
Custom Windows 10 Partitionjng IN UEFI System
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
DISKPART - How to Partition GPT disk -
Windows 10 Help Forums
How to Use DISKPART Script to Partition GPT Disk for Single and
Dual Boot Scenarios
Published by Kari "Kalsarikanni" FinnCategory: Installation & Upgrade
10 Jan 2018
Information
Some time ago in another thread | promised a fellow Ten Forums
member, esteemed geek and a good friend of mine Tony K to
make him a custom DISKPART script when needed:
Kari said
Tony K said:
My system at present is MBR. When the Fall update is released I
want to convert to GPT. This will make it a whole lot easier.
Just let me know when you need a DISKPART script, | can make a
custom script to you based on how you want to partition the
system disk (disk where Windows will be installed). The script |
posted is quite basic, to partition a disk where all available space
after system partitions will be used for Windows partition. In case
you want more data partitions on the same disk, the script needs
to be modified
Well, a few days ago Tony sent a PM telling what he wants to do:
Dual boot Windows 10 Fall Creators Update and Fast Ring
Windows Insider Fast Ring builds, doing this on small 120 GB SSD
which is currently partitioned as an MBR disk but should be
partitioned as GPT disk in new dual boot setup. He also has an
additional 2 TB HDD for data. Instead of simply replying to him, |
decided to make a tutorial about this process because this might
benefit other fellow members, too.
This tutorial could have been named as "Dual Boot - The Easy
Way"In this tutorial we will use DISKPART to convert an MBR disk to
GPT, partition the disk following Microsoft's guidelines, and install
‘two operating systems on it (we'll cover single OS partitioning and
setup, too).
Here's a screenshot of Tony's Disk Management before we start:
(Click to enlarge.)
z
Note
Please notice that although the tutorial might look somewhat long
and complicated, procedure itself to use DISKPART script to
partition HDD and install two operating systems as told in this
tutorial is quite easy. If you are not interested in "under the hood"
information about DISKPART, how the script works and want to get
going faster, grab the script from step 2.3, and jump directly to
step 3.1
Contents
Use links below to go to any step, back button of your browser to
return to this list.
Step One: | Preparations - Create USB install media
Step Two: | Preparations - Create DISKPART Script
Step Three: | Boot from USB
Step Four: | Run DISKPART script
Step Five: | Install Primary OS
Step Six: | Install Secondary OSStep One
Preparations - Create USB install media
1.1) Download Windows 10 ISO image or create one from Insider
or Feature Upgrade UUP files:
1.2) Create a bootable USB flash drive install media for Windows
10 version and edition you want to install (primary operating
system in dual boot) as told in following tutorial: PowerShell
Scripting - Create USB Install Media for Windows 10 Installation
Upgrade Tutorials
Step Two.
Preparations - Create DISKPART Script
2.1) A DISKPART script is a text file with extension .txt containing
all necessary DISKPART commands. It can be made and edited
with Notepad
2.2) Each line is one command with possible parameters. A line
starting with REM (remark, not case sensitive) will be ignored,
allowing explanations and comments to be added. Even if the
script will only be used by yourself, I recommend adding as many
REM lines as required to help you to better remember, understand
and see what script does also in the future
2.3) The script | made for Tony is in CODE box below, with REM
lines to explain what each command is doing. You can and of
course should edit it to meet your needs. We will go through the
script command by command but for those anxious to get started,
just copy the script, paste it in Notepad and edit.
Script One: DISKPART script to partition a HDD / SSD for dual
boot, or for separate Windows and Data partitions:
Code:
rem DISKPART script for single disk dual boot
rem OS 1: Windows 1@ Fall Creators Update (W1@ FCU)
rem OS 2: Windows 1@ Insider Preview (W1@ IP)
rem -
rem Select Disk, wipe it empty, convert to GPT
remselect disk @
clean
convert gpt
rem
rem -
rem Create & format 100 MB EFI System partition
rem
create partition efi size=100
format quick fs=fat32 labe:
rem
system"
rem -
rem Create 16 MB MSR partition (will not be
formatted)
rem
create partition msr size=16
rem
rem -
rem Create a 52 GB (53,248 MB) partition for
primary 0S
rem
3248
create partition primary siz
rem
rem -
rem Format OS partition, label it, assign drive
letter
rem W. Windows Setup will change this drive letter
to ¢
rem when installed. It's important now to use a not
rem reserved letter, therefore we use a letter from
rem end of alphabet
rem
format quick fs=ntfs label="W1e@ FCU"
assign lette
rem
rem -
rem Create & format a 45@ MB recovery partition.
rem Notice that ID must be set exactly as shown!
remcreate partition primary size=450
format quick fs=ntfs label="WinRE"
set id="de94bba4-06d1-4d40-a16a-bfd5S@179d6ac”
rem
rem -
rem Create partition for 2nd OS using all free
space
rem
create partition primary
rem
rem -
rem Format 2nd OS partition, label it, no drive
letter
rem
format quick fs=ntfs label="W1 IP"
rem
rem -
rem Exit Diskpart
rem
exit
Script Two: An alternative DISKPART script to partition a HDD /
SSD for single OS assigning all available space to system
(Windows) partition:
Code:
rem DISKPART script for single disk dual boot
rem OS: Windows 1@ (any version & edition)
rem -
rem Select Disk, wipe it empty, convert to GPT
rem
select disk @
clean
convert gpt
rem
rem -rem Create & format 100 MB EFI System partition
rem
create partition efi size=100
format quick fs=fat32 labe:
rem
system"
rem -
rem Create 16 MB MSR partition (will not be
formatted)
rem
create partition msr size=16
rem
rem -
rem Create OS partition using all available space,
rem shrink it with 45@ MB to leave space at end of
HDD
rem for WinRE partition
rem
create partition primary
shrink minimum=45@
rem
rem -
rem Format OS partition, label it, assign drive
letter
rem W. Windows Setup will change this drive letter
toc
rem when installed. It's important now to use a not
rem reserved letter, therefore we use a letter from
rem end of alphabet
rem
format quick fs=ntfs label="Windows 10”
assign letter=
rem
rem -
rem Create & format WinRE recovery partition at the
rem end of the disk. Not defining the size, it will
use
rem all available space, 50@ MB that we shrunk OS
rem partition with. Notice that ID must be set
exactlyrem as shown!
rem
create partition primary
format quick fs=ntfs label="WinRE"
set id="deo4bba4-06d1-4d40-a16a-bfd5e179d6ac"
rem
rem -
rem Exit Diskpart
rem
exit
2.4) First set of DISKPART commands in script selects DISK 0,
the primary disk which in most cases is correct (more about this
in step 3.4), the disk where Windows will be installed, then wipes it
clean and finally converts disk to GPT even if the disk previously
already was a GPT disk:
[sel disk @
clean
(convert gpt|
4
Note
If you are using DISKPART command line entering commands one
by one instead of running script, you need first to start DISKPART
with command (diskparty then enter above commands one by
one pressing ENTER after each command. Be careful selected
disk will be wiped clean without any warnings (how to check disk
ID, see Step 3.4)!
2.5) The first partition will be a 100 MB EFI system partition
formatted in FAT32 file system. We will create, format and label it
with following two commands:
{create partition efi size-1002.6) Next, the 16 MB MSR (Microsoft Reserved) partition. This
partition will not be formatted, nor will it get a label:
create partition msr size=16
2.7) Now the primary OS partition. In this example using Tony's
120 GB SSD, | will make it a 52 GB (53,248 MB) partition. You can
of course make the partition exactly as big or small as you wish,
minimum size recommended for Windows 10 is 25 GB:
(create partition primary size=53248|
~f
Note
If you are partitioning disk only for a single Windows partition
using all disk capacity (Script Two in step 2.3), use following
commands to create Windows and WinRE partitions and jump
then to step 2.11 skipping 2.8 through 2.10:
Code:
create partition primary
shrink minimum=45@
format quick fs=ntfs label="Windows"
create partition primary
format quick fs=ntfs label="WinRE"
de94bba4-26d1-4d40-a16a-bfd50179d6ac"
The above set of DISKPART commands first creates a partition for
Windows using all available space, then shrinks it from end of
partition with 450 MB and then creates a 450 MB WinRE partition
on that space.
2.8) | will format OS partition as NTFS and label it as W10 FCU,
assigning it drive letter W: (I car't use currently reserved drive
letters, Windows setup will later automatically change it to C:):
Wie FCU”jassign letter=
You can of course label your Windows partition as you prefer, W10
FOU here is just an example.
2.9) The recovery partition (WinRE) will be placed between
primary OS partition and secondary OS partition. WinRE partition
is the only partition that can expand "backwards"; future upgrades
requiring more space on WinRE will shrink the C: (primary 0S)
partition:
“The Windows Recovery pation on a GPT disk has a unique trait no other partition hast can
expand “backwards” taking extra space from partion pracecig it. Usualy partitions can only
expand “lorwares se ree unallocated space after them but i recovery partition spaced directly
aftr €: partition it forces Cta shank when it needs more space allocating Ico sel
Here the same cl from same machine than in prewoiscereenchot after upgraded ito ltect
Windows Insicer bul:
Instead of creating an adctional partion, recovery partition took the extra 8 MBit needed for
‘upgrade (possible rolhtac to previous bul) by shrinking: and allocating tat space to sell,
We will create WinRE partition with following commands. Please
notice, WinRE partition requires an ID which must be exactly as.
shown:
create partition primary size-450
‘format quick fs=ntfs label="WinRE"
‘set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac”
2.10) Finally, we'll create partition for secondary OS using all
available space left on disk, format and label it but do not assign a
drive letter, then exit DISKPART with following commands:
(create partition primar:
‘format quick fs=ntfs label="w1e IP"exit
2.11) Save the script as DiskOConfig.txt on your Windows install
USB
z
Note
A couple of times I've seen a UEFI PC with GPT partitioning to list
the boot USB as disk 0, and Windows system disk as disk 1
| always prepare myself for this oddity by saving the original script
as DiskOConfig.ttt, then saving another copy of it as
Disk1Config,txt with one small but important change: I'll edit disk
selection command sel disk 0 as seen in step 2.4, the very first
command in script to read sel disk 1, to select disk 1 instead of
disk 0.
This way | am prepared, having a script regardless if the Windows
system disk is listed as disk 0 or disk 1
Step Three
Boot from USB
3.1) Boot the PC from your Windows 10 install media (USB flash
drive)
3.2) on region and language selection screen, press SHIFT + F10
to open Command Prompt:3.3) Type {diskpart| and press Enter to launch Windows Disk
Partition Utility DISKPART, type list disk and press Enter to list
available disks, type [list _volland press Enter to list available
volumes, type [exit] and press Enter to exit DISKPART (commands
highlighted with yellow in screenshot in next step)
3.4) Note the disk number for Windows system disk shown after
command list diskl In most cases itis disk 0, but can
occasionally be shown as disk 1 (see note in step 2.7). In this
sample case itis as it should be, disk 0. Also note the drive letter
for your USB install media shown after command list voll, In
this example itis drive E:
Step Four
Run DISKPART script
4,1) in steps 3.3 & 3.4 | found out that my Windows system disk
is disk 0 and USB drive containing Windows setup files and
DISKPART scripts is drive E:
4.2) | can now run DISKPART again, this time telling it with switch
/s that | want to run a script DiskOConfig.txt (Disk1Config. txt if |
had found out that system disk this time had been disk 1):
diskpart /s E:\DiskeConfig.txtScript in action (video length 32 seconds):
4.3) Close Command Prompt
Step Five
Install Primary OS
5.1) Continue installation normally:
eae
Clean install tutorial: Clean Install Windows 10 Installation
Upgrade Tutorials
5.2) system disk is partitioned exactly as told in script we run in
4.2. Select the Windows partition (partition for primary OS in dual
boot scenario) and click Next, in this example my script labelled it
as W10 FCU (Fall Creators Update):© ivinsoesep
‘Where do you want to install Windows?
gp Dive atin: s¥sTEM
DrveOPattion2
Dine O Patton 3 wo FOU
Tine Panton Wie
gp Dive Panton wa0P
Mp Beiesn Kosee
iowsne herons
Step Six
Install Secondary OS
00 Me
s60Me
52058
TONE
550M Sten
260 MBSR Rese
519.58 Pay
SOME Reconey
581.98 ray
Parente
6.1) open Disk Management, right click partition reserved for
secondary 0S, select Change Drive Letter and Paths and add a
drive letter to this partition. Remember, it is currently without drive
letter therefore not shown in Explorer because in DISKPART script
we didn't assign any letter to it. See tutorial if you need any help in
assigning a drive letter: Change and Assign Drive Letter in
Windows 10 Hardware Drivers Tutorialseach
ony en
In this example | assigned letter Z: to this partition
6.2) Download (or copy from another PC) ISO image for the
secondary 0S, for instance a Windows Insider ISO or another
edition of same version as primary OS. Mount it as virtual DVD by
right clicking ISO file and selecting Mount. Note the drive letter ISO
got when mounted. In this example mounted |SO is drive G:
6.3) Open an elevated PowerShell (tutorial)
6.4) Type following command and press Enter, replacing drive
letter for mounted ISO (6: in this example) in /WimFile switch with
actual drive letter:
(dism /Get-WimInfo /WimFil
:\Sources\install.wim|
Note the index number to the edition you want to install as
secondary OS. In this example | want to install Enterprise edition,
index 3:z
Note
Default path to install.wim file is DRIVE:\Sources \install.wim. If
you are using an ESD based ISO, or a dual bit architecture ISO, you
need to change the path in above command accordingly:
~In an ESD based ISO the path is DRIVE:\Sources\install.esd
In dual bit architecture ISO the path is
DRIVE:\x86\Sources\install.wim (or install.esd) for 32 bit W10
In dual bit architecture ISO the path is
DRIVE:\x64\Sources\install.wim (or install.esd) for 64 bit W10
6.5) Type the following command, replacing drive letter for
secondary OS partition (Z:\ in this example) in /ApplyDir switch
and mounted ISO drive letter (G: in this example) in /ImageFile
switch. Same rules apply as in note in step 6.4 if you are using an
ESD based ISO or a dual bit architecture ISO. Be sure to use
correct index number:
dism /Apply-Image /ImageFile:
Findex:3 /ApplyDir:Z:\|
:\Sources\install.wim
6.6) Press Enter, installation starts:
Depending on your hardware performance, this takes anythingfrom a minute and a half to 10 minutes. You can freely browse the
web or use your PC for anything else while DISM applies Windows
image for your secondary 0S, Windows is quite good in
multitasking
6.7) When done, the secondary Windows needs to be added to
boot menu. Do this with following command (#1 in screenshot in
step 6.11), replacing the secondary OS drive letter (Z: in this,
example) with the actual one:
bedboot Z:\Windows|
6.8) Secondary OS was added as default OS to boot menu, the
OS which will be booted if user makes no selection within given
timeframe (30 seconds by default). We leave it as default OS for
now
6.9) All Windows 10 operating systems are by default listed as
Windows 10 on boot menu, regardless of their edition. It is better
to change boot entry names to more individual ones, to be sure
correct OS will be selected when boot menu is shown. For that we
will need command bededit. However, as bededit switches do not
work in PowerShell we need first switch PowerShell to Command
Prompt mode.
This is done with a simple command (emd| (#2 in screenshot in
6.11)
6.10) As the secondary OS is at the moment the default 0S, its
identifier is (default). 1 want to change its description, boot menu
entry to W10 Enterprise, doing it with following command (#3 in
screenshot in 6.11, description in quotes if it contains spaces):
bcdedit /set {default} description "wie Enterprise”
6.11) Current OS we are booted to at the moment, the primary
‘one has identifier {current}. | want to change it to W10 Pro (#4 in
screenshot):
\bcdedit /set {current} description "W10 Pro"6.12) Close PowerShell, restart PC
6.13) We left secondary OS default for now because finalizing
Windows setup still needs two restarts. Being default OS it will be
automatically booted if user makes no selection within given
timeframe, by default 30 seconds:
You can leave PC to finish setting up secondary OS and restart to
it and have a break
6.14) When on desktop after secondary OS has finished the
setup, press WIN + Rto open RUN prompt, type fnsconfig and
press Enter to open System Configuration. Select the Boot tab,
select your primary OS and click Set as default. Click OK to
confirm:@ System Configuration im
eneral 856% Services| Startup Tos
“Aévareadoptore.._|[ Seton defait ‘oat
oot pts sei
sare toot | ve cutest [a sees
ial Beet oo
Arte shel Bese ven
acto niet par os bet nfraten (Cate a boot settnas
et perrent
ced) coeet | | ay ee
6.15) Click restart and boot back to primary OS:
System Configuration x
You may need to restart your computer to apply these changes,
Before restarting, save any open files and close all programs.
6.16) Both operating systems have now been installed, primary
OS set as default:That's it geeks!
Kari