Microsoft DOS diskpart command
The diskpart command is a recovery console command that enables a user to delete and create partitions on their computer.
Windows Vista, 7, 8, 10 diskpart command syntax
Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: COMPUTERHOPE
Microsoft DiskPart syntax:
diskpart [/s <script>] [/?]
|/s <script>||Use a DiskPart script.|
|/?||Show this help screen.|
Typing diskpart from an elevated command prompt will enter the "DISKPART>" prompt. From this prompt, the following commands are available. These commands are also available from a DiskPart script.
|ACTIVE||Mark the selected partition as active.|
|ADD||Add a mirror to a simple volume.|
|ASSIGN||Assign a drive letter or mount point to the selected volume.|
|ATTRIBUTES||Manipulate volume or disk attributes.|
|ATTACH||Attaches a virtual disk file.|
|AUTOMOUNT||Enable and disable automatic mounting of basic volumes.|
|BREAK||Break a mirror set.|
|CLEAN||Clear the configuration information, or all information, off the disk.|
|COMPACT||Attempts to reduce the physical size of the file.|
|CONVERT||Convert between different disk formats.|
|CREATE||Create a volume, partition, or virtual disk.|
|DELETE||Delete an object.|
|DETAIL||Provide details about an object.|
|DETACH||Detaches a virtual disk file.|
|EXTEND||Extend a volume.|
|EXPAND||Expands the maximum size available on a virtual disk.|
|FILESYSTEMS||Display current and supported file systems on the volume.|
|FORMAT||Format the volume or partition.|
|GPT||Assign attributes to the selected GPT partition.|
|HELP||Display a list of commands.|
|IMPORT||Import a disk group.|
|INACTIVE||Mark the selected partition as inactive.|
|LIST||Display a list of objects.|
|MERGE||Merges a child disk with its parents.|
|ONLINE||Online an object that is currently marked as offline.|
|OFFLINE||Offline an object that is currently marked as online.|
|RECOVER||Refreshes the state of all disks in the selected pack. Attempts recovery on disks in the invalid pack, and resynchronizes mirrored volumes and RAID5 volumes that have stale plex or parity data.|
|REM||Does nothing and is used to comment scripts.|
|REMOVE||Remove a drive letter or mount point assignment.|
|REPAIR||Repair a RAID-5 volume with a failed member.|
|RESCAN||Rescan the computer looking for disks and volumes.|
|RETAIN||Place a retained partition under a simple volume.|
|SAN||Display or set the SAN policy for the currently booted OS.|
|SELECT||Shift the focus to an object.|
|SETID||Change the partition type.|
|SHRINK||Reduce the size of the selected volume.|
|UNIQUEID||Displays or sets the GUID partition table (GPT) identifier or master boot record (MBR) signature of a disk.|
Recovery Console diskpart command syntax
Creates and deletes partitions on a hard drive. The below diskpart command information is only available when you are using the Recovery Console.
diskpart [/add | /delete] [device_name | drive_name | partition_name] [size]
|/add||Creates a new partition.|
|/delete||Deletes an existing partition.|
|device_name||The device you want to create or delete a partition. The name can be obtained from the output of the map command.|
|drive_name||The partition you want to delete, by drive letter. Used only with /delete.|
|partition_name||The partition you want to delete, by partition name. Can be used in place of the drive_name. Used only with /delete.|
|size||The size, in megabytes (MB), of the partition you want to create. Used only with /add.|
Typing diskpart without any additional switches or options opens a new DISKPART> prompt and allows all the above commands to be entered. For example, while at the DISKPART> prompt, you can type LIST DISK and get an output similar to the example below.
Disk ### Status Size Free Dyn Gpt -------- ------------- ------- ------- --- --- Disk 0 Online 476 GB 449 MB Disk 1 Online 2047 GB 0 B Disk 2 No Media 0 B 0 B Disk 3 No Media 0 B 0 B Disk 4 No Media 0 B 0 B Disk 5 No Media 0 B 0 B
Note: When entering the diskpart command in some versions of Windows, you may receive a UAC warning. You must accept this warning before diskpart can open.
Tip: To exit the DISKPART> prompt, type exit and press Enter.
diskpart /delete D:
In the above example, the D: partition would be deleted.
diskpart /add \Device\HardDisk0 20
In the above example, a 20 MB partition would be created on the HardDisk0 device.
Tip: The drive name is obtained from the map command.