DISKPART is a Windows program that replaces FDISK. FDISK only works with MBR partitions. DISKPART works on MBR and GPT partitions.
Type HELP DISKPART in a command window to see all the options for DISKPART.
Open a command window as an administrator in order to call DISKPART.
DISKPART can be used interactively or can be called from scripts. The following can be issued in interactive mode, after typing DISKPART in a command window.
To run DISKPART from a script file, place DISKPART commands in a text file (not .bat) and execute the script file with
DISKPART /S MYFILE.TXT
LIST DISK
SELECT DISK N
SELECT DISK command.
CONVERT TYPE
SELECT DISK command.
Type can be BASIC or DYNAMIC for converting between the type of disk; type can be MBR or GPT for converting between type of partition table. GPT has a minimum size restriction.
CREATE PARTITION TYPE SIZE=N
SELECT DISK command. The type of the partition can be primary, extended or logical.
LIST PARTITION
SELECT DISK command.
SELECT PARTITION N
SELECT DISK command.
FORMAT FS=TYPE LABEL=TEXT
SELECT PARTITION command.
Type is either FAT or NTFS.
LABEL is a string that appears in Windows Explorer that helps identify the partition.
If the string has spaces, enclose the string in quotes.
LIST VOLUME
Before working on a disk or partition, it must be selected.
Help for any command can be listed with HELP COMMAND.
If a command has options, then help on the option can be obtained with HELP COMMAND OPTION.
Create a text file with DISKPART commands.
list disk select disk 1 list partition
Run DISKPART from an administrator's command window:
DISKPART /S MYSCRIPT.TXT
The output of the command will look something like
Microsoft DiskPart version 6.2.9200 Copyright (C) 1999-2012 Microsoft Corporation. On computer: WIN8-HOME Disk ### Status Size Free Dyn Gpt -------- ------------- ------- ------- --- --- Disk 0 Online 40 GB 1024 KB Disk 1 Online 20 MB 8128 KB Disk 2 Online 20 MB 20 MB Disk 1 is now the selected disk. Partition ### Type Size Offset ------------- ---------------- ------- ------- Partition 1 Primary 4096 KB 64 KB Partition 5 Primary 7168 KB 10 MB
Redirect the output to a file with:
DISKPART /S MYSCRIPT.TXT > DISKPART.OUT.TXT