Home
> Commands A-M
> Commands Da-Dr
DISKPART
Description
| Syntax
| Parameters
| Switches
| Related
| Notes
| Examples
| Errorlevels
| Availability
Text-mode command interpreter that enables you to
manage objects (disks, partitions, or volumes) by using
scripts or direct input from a command prompt.
Syntax
DISKPART
/?
DISKPART
[/s script_file]
Commands to run at the DISKPART prompt:
Parameters
- all
(NTXP)
- Clean:
Specifies that each and every sector on the disk
is zeroed, which completely deletes all data
contained on the disk.
- Remove:
Removes all current drive letters and mount points.
- active
(NTXP)
- On basic disks, marks the partition with focus as
active. This informs the basic input/output system
(BIOS) or Extensible Firmware Interface (EFI) that the
partition or volume is a valid system partition or
system volume.
- Only partitions can be marked as active.
- Important: Verifies only that the partition
is capable of containing an operating system's startup
files. Does not check the contents of the partition.
If you mistakenly mark a partition as "active" and it
does not contain the operating system's startup files,
your computer might not start.
- add
(NTXP)
- Mirrors the simple volume with focus to the
specified disk.
- assign
(NTXP)
- Assigns a drive letter or mount point to the
volume with focus. If no drive letter or mount point
is specified, then the next available drive letter is
assigned. If the drive letter or mount point is
already in use, an error is generated.
- By using the assign command, you can change the
drive letter associated with a removable drive.
- You cannot assign drive letters to system volumes,
boot volumes, or volumes that contain the paging file.
In addition, you cannot assign a drive letter to an
Original Equipment Manufacturer (OEM) partition or any
GUID Partition Table (GPT) partition other than a
basic MSDATA partition.
- automount
(NT2003)
- When enabled (the default), Windows automatically
mounts the file system for a new basic volume when it
is added to the system and then assigns a drive letter
to the volume. In system area network configurations,
disabling automount prevents Windows from
automatically mounting or assigning drive letters to
any new basic volumes that are added to the system.
- break
(NTXP)
- Applies to dynamic disks only. Breaks the mirrored
volume with focus into two simple volumes. One simple
volume retains the drive letter and any mount points
of the mirrored volume, while the other simple volume
receives the focus so you can assign it a drive letter.
- By default, the contents of both halves of the
mirror are retained. Each half becomes a simple
volume. By using the nokeep parameter, you retain only
one half of the mirror as a simple volume, while the
other half is deleted and converted to free space.
Neither volume receives the focus.
- clean
(NTXP)
- Removes any and all partition or volume formatting
from the disk with focus. On master boot record (MBR)
disks, only the MBR partitioning information and
hidden sector information are overwritten. On GUID
Partition Table (GPT) disks, the GPT partitioning
information, including the Protective MBR, is
overwritten. There is no hidden sector information.
- convert basic
(NTXP)
- Converts an empty dynamic disk into a basic disk.
- convert dynamic
(NTXP)
- Converts a basic disk into a dynamic disk.
- convert gpt
(NTXP)
- On Itanium-based computers, converts an empty
basic disk with the master boot record (MBR) partition
style into a basic disk with the GUID partition table
(GPT) partition style.
- Important: The disk must be empty to
convert it to a GPT disk. Back up your data and then
delete all partitions or volumes before converting the
disk.
- convert mbr
(NTXP)
- On Itanium-based computers, converts an empty
basic disk with the GUID Partition Table (GPT)
partition style to a basic disk with the master boot
record (MBR) partition style.
- Important: The disk must be empty to
convert it to an MBR disk. Back up your data and then
delete all partitions or volumes before converting the
disk.
-
(create partition efi
NTXP)
- On Itanium-based computers, creates an Extensible
Firmware Interface (EFI) system partition on a GUID
Partition Table (GPT) disk. After the partition has
been created, the focus is given to the new partition.
-
(create partition extended
NTXP)
- Creates an extended partition on the current
drive. After the partition has been created, the focus
automatically shifts to the new partition. Only one
extended partition can be created per disk. This
command fails if you attempt to create an extended
partition within another extended partition. You must
create an extended partition before you can create
logical drives.
-
(create partition logical
NTXP)
- Creates a logical drive in the extended partition.
After the partition has been created, the focus
automatically shifts to the new logical drive.
- If you specify size=,
it must be smaller than the extended partition.
-
(create partition msr
NTXP)
- On Itanium-based computers, creates a Microsoft
Reserved (MSR) partition on a GUID Partition Table
(GPT) disk.
- Caution: Be very careful when using the
create partition msr command. Because GPT disks
require a specific partition layout, creating
Microsoft reserved partitions could cause the disk to
become unreadable. On GPT disks that are used to start
Windows XP 64-Bit Edition, the EFI System partition is
the first partition on the disk, followed by the
Microsoft Reserved partition. GPT disks used only for
data storage do not have an EFI System partition; the
Microsoft Reserved partition is the first partition.
- Windows XP 64-Bit Edition does not mount Microsoft
reserved partitions. You cannot store data on them and
you cannot delete them.
-
(create partition primary
NTXP)
- Creates a primary partition on the current basic
disk After you create the partition, the focus
automatically shifts to the new partition. The
partition does not receive a drive letter. You must
use assign to assign a
drive letter to the partition.
-
(create volume raid
NTXP)
- Creates a RAID-5 volume on the specified dynamic
disks After you create the volume, the focus
automatically shifts to the new volume.
-
(create volume simple
NTXP)
- Creates a simple volume After you create the
volume, the focus automatically shifts to the new
volume.
-
(create volume stripe
NTXP)
- Creates a striped volume on the specified disks.
After you create the volume, the focus automatically
shifts to the new volume.
- d
(NTXP)
- The drive letter or mount point path of the
partition/volume to receive the focus.
- delete disk
(NTXP)
- Deletes a missing dynamic disk from the disk list.
- delete partition
(NTXP)
- On a basic disk, deletes the partition with focus.
You cannot delete the system partition, boot partition,
or any partition that contains the active paging file
or crash dump (memory dump).
- Caution: Deleting a partition on a dynamic
disk can delete all offline dynamic volumes on the
disk, thus destroying any data and converting the disk
to a basic disk. To delete a dynamic volume, always use
delete volume
instead.
- Partitions can be deleted from dynamic disks, but
they should not be created. Intended to allow
reclamation of the space on a corrupted offline
dynamic disk in an emergency situation where
clean cannot be used.
- delete volume
(NTXP)
- Deletes the selected volume. You cannot delete the
system volume, boot volume, or any volume that
contains the active paging file or crash dump (memory
dump).
- detail disk
(NTXP)
- Displays the properties of the selected disk and
the volumes on that disk.
- detail volume
(NTXP)
- Displays the disks on which the current volume
resides.
- disable | enable
(NT2003)
- Disables/enables Windows automatically mounting
new basic volumes that are added to the system and
assigning them drive letters.
- disk=n
(NTXP)
- Specifies the disk to contain the mirror You can
mirror only simple volumes. The specified disk must
have unallocated space at least as large as the size
of the simple volume you want to mirror.
- disk=n[,n ...]
(NTXP)
- The dynamic disks on which to create the volume.
An amount of space equal to
size=n is allocated on
each disk.
- dismount
(NT2003)
- Dismounts the basic volume basic volume, when all
drive letters and mount points have been removed from
the volume, and takes the basic volume offline, making
it unmountable. If other processes are using the
volume, any open handles are closed
before dismounting the volume. You can make the volume
mountable by assigning it a driver letter or by
creating a mount point path to the volume.
Dismount will fail if used on a volume that has any
remaining drive letters or mount points.
Recommended scripting use:
remove
all
dismount.
- The dynamic disks on which to create the volume.
each disk.
- exit
(NTXP)
- Exits the command interpreter.
- extend
(NTXP)
- Extends the volume with focus into next contiguous
unallocated space. For basic volumes, the unallocated
space must be on the same disk as, and must follow (be
of higher sector offset than) the partition with
focus. A dynamic simple or spanned volume can be
extended to any empty space on any dynamic disk Using
this command, you can extend an existing volume into
newly created space.
- If the partition was previously formatted with the
NTFS file system, the file system is automatically
extended to occupy the larger partition. No data loss
occurs. If the partition was previously formatted with
any file system format other than NTFS, the command
fails with no change to the partition.
- You cannot extend the current system or boot
partitions.
- gpt attributes=n
(NT2003)
- On basic GPT disks, assigns the GPT attribute(s)
to the partition with focus. GPT partition attributes
give additional information about the use of the
partition. Some attributes are specific to the
partition type GUID.
- Important: Changing the GPT attributes
might cause your basic data volumes to be unmountable
or fail to be assigned drive letters. Unless you are
an original equipment manufacturer (OEM) or an IT
professional experienced with GPT disks, do not change
GPT attributes.
- The hexadecimal that pertains to the attribute
that you want to apply to the partition with focus.
The GPT attribute field is a 64-bit field that
contains two subfields. The higher field is
interpreted only in the context of the partition ID,
while the lower field is common to all partition IDs.
- 0x0000000000000001 marks the partition as required.
This indicates to all disk management utilities that
the partition should not be deleted. The EFI System
partition contains only those binaries necessary to
start the operating system. This makes it easy for
OEM- or operating system-specific binaries to be
placed in other partitions (all partitions have this
attribute).
- 0x8000000000000000 prevents the partition from
having a drive letter automatically assigned. By
default, each partition is assigned a new drive letter.
Setting this attribute ensures that when a disk is
moved to a new computer, a new drive letter will not be
automatically generated. Instead, the user can
manually assign drive letters (basic data partitions).
- Note: Other attributes can be added at any
time.
- help
(NTXP)
- Displays a list of the available commands.
- ID={byte | GUID}
(NTXP)
- Intended for Original Equipment Manufacturer (OEM)
use only.
- Caution: Creating partitions with this
parameter might cause your computer to crash or be
unable to start up. Unless you are an OEM or an IT
professional experienced with GPT disks, do not create
partitions on GPT disks using the ID=byte | GUID
parameter. Instead, always use
create partition efi
to create EFI System partitions, the
create partition msr
to create Microsoft Reserved partitions, and the
create partition primary
(without the ID=byte | GUID parameter) to create
primary partitions on GPT disks.
- For MBR disks, you can specify a partition type
byte, in hexadecimal form, for the partition. If no
partition type byte is specified on an MBR disk, the
create partition primary
creates a partition of type 0x6.
- For GPT disks you can specify a partition type
GUID for the partition you want to create:
- EFI System partition: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
- Microsoft reserved partition: e3c9e316-0b5c-4db8-817d-f92df00215ae
- MSDATA partition: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
- LDM Metadata partition on a dynamic disk: 5808c8aa-7e8f-42e0-85d2-e1e90434cfb3
- LDM Data partition on a dynamic disk: af9b60a0-1431-4f62-bc68-3311714a69ad
If no partition type GUID is specified, the
create partition primary
creates an MSDATA partition.
- Any partition type can be
specified with the ID={byte | GUID} parameter.
Does not check the partition GUID for
validity, nor does it perform any other checking of
the ID parameter.
- import
(NTXP)
- Imports a foreign disk group into the local
computer's disk group. Imports every disk that is in
the same group as the disk that has focus.
- inactive
(NT2003)
- On basic master boot record (MBR) disks, marks the
system partition system partition or boot partition
with focus as inactive. The computer starts from the
next option specified in the BIOS such as the CD-ROM
drive or a Pre-Boot eXecution Environment (PXE)-based
boot environment (such as Remote Installation Services
(RIS) Remote Installation Services (RIS) when you
restart the computer.
- Caution: Your computer might not start
without an active partition active partition. Do not
mark a system or boot partition as inactive unless you
are an experienced user with a thorough understanding
of the Windows (Server) family of operating systems.
- If you are unable to start your computer after
marking the system or boot partition as inactive,
insert the Setup CD in the CD-ROM drive, restart the
computer, and then repair the partition using the
Fixmbr and Fixboot commands in the
Recovery Console.
- letter=d
(NTXP)
- The drive letter you want to assign/remove
to/from the volume.
- list disk
(NTXP)
- Displays a list of disks and information about
them, such as their size, amount of available free
space, whether the disk is a basic or dynamic disk,
and whether the disk uses the master boot record (MBR)
or GUID partition table (GPT) partition style. The
disk marked with an asterisk (*) has focus.
- list partition
(NTXP)
- Displays the partitions listed in the partition
table of the current disk. On dynamic disks, these
partitions may not correspond to the dynamic volumes
on the disk. This discrepancy occurs because dynamic
disks contain entries in the partition table for the
system volume or boot volume (if present on the disk)
and a partition that occupies the remainder of the
disk in order to reserve the space for use by dynamic
volumes.
- list volume
(NTXP)
- Displays a list of basic and dynamic volumes on
all disks.
- mount=path
(NTXP)
- The mount point path you want to assign/remove
to/from the volume.
- n
(NTXP)
- The disk number of the disk/partition/volume
to receive focus.
- noerr
(NTXP)
- For scripting only.
When an error is encountered, specifies continue to
process commands as if the error did not occur.
If omitted, an error causes exit with an error code.
- nokeep
(NTXP)
- Specifies that only one of the mirrored volumes
is retained; the other simple volume is deleted and
converted to free space. Neither the volume nor the
free space receive the focus.
- offset=n
(NTXP)
- Applies to master boot record (MBR) disks only.
The byte offset at which to create the partition
If no offset is given, the partition is placed in
the first disk extent that is large enough to hold
it. The offset is cylinder snapped. The offset is
rounded to the closest cylinder boundary.
- online
(NTXP)
- Brings an offline disk or volume with focus
online.
- override
(NTXP)
- Enables deletion of all simple volumes on
the disk. If the disk contains half of a mirrored
volume, the half of the mirror on the disk is deleted.
The delete disk
override command fails if the disk is a member of a
RAID-5 volume.
- Enables deletion of any partition
regardless of type. Typically, only allowed
to delete known data partitions.
- rem
(NTXP)
- Provides a way to add comments to a script.
- remove
(NTXP)
- Removes a drive letter or mount point from the
volume with focus. If all
is used, all current drive letters and mount points
are removed. If no drive letter or mount point is
specified, then removes the first drive
letter or mount point it encounters.
- Can be used to change the drive
letter associated with a removable drive. You cannot
remove the drive letters on system, boot, or paging
volumes. In addition, you cannot remove the drive
letter for an OEM partition, any GPT partition with an
unrecognized GUID, or any of the special, non-data,
GPT partitions such as the EFI system partition.
- repair disk=n
(NT2003)
- Repairs the RAID-5 volume with focus by replacing
the failed RAID-5 member with the specified dynamic
disk. The specified dynamic disk must have free space
greater than or equal to the total size of the failed
RAID-5 member.
- rescan
(NTXP)
- Locates new disks that may have been added to the
computer.
- retain
(NTXP)
- Prepares an existing dynamic simple volume to be
used as a boot or system volume.
- On an x86-based computer, creates a partition
entry in the master boot record (MBR) on the dynamic
simple volume with focus. To create an MBR partition,
the dynamic simple volume must start at a cylinder
aligned offset and be an integral number of cylinders
in size.
- On an Itanium-based computer, creates a partition
entry in the GUID partition table (GPT) on the dynamic
simple volume with focus.
- Note: Intended for use only during
Unattended Setup or by Original Equipment
Manufacturers (OEMs).
- scrub
(NT2003)
- Removes volume mount point directories and
registry settings for volumes that are no longer in
the system. This prevents volumes that were previously
in the system from being automatically mounted and
given their former volume mount point(s) when they are
added back to the system.
- select disk
(NTXP)
- Selects the specified disk and shifts the focus to
it. If no disk number is specified, lists the disk
that currently has the focus. You can view the numbers
for all disks on the computer by using
list disk.
- select partition
(NTXP)
- Selects the specified partition and gives it
focus. If no partition is specified, lists the current
partition with focus. You can view the numbers of all
partitions on the current disk by using
list partition.
- select volume
(NTXP)
- Selects the specified volume and shifts the focus
to it. If no volume is specified, lists the current
volume with focus. You can specify the volume by
number, drive letter, or mount point path. On a basic
disk, selecting a volume also gives the corresponding
partition focus. You can view the numbers of all
volumes on the computer by using
list volume.
- size=n
(NTXP)
- The size of the partition in megabytes (MB). If
no size is given, then the partition continues until
there is no more free space in the current region.
The size is cylinder snapped. The size is rounded to
the closest cylinder boundary.
Switches
- /?
(NTXP)
- Display help.
- /s script_file
(NTXP)
- Use DISKPART script.
Related
none.
Notes
none.
Examples
none.
Errorlevels
- 0 No errors occurred
- 1 A fatal exception occurred. There may be a serious problem
- 2 The parameters specified were incorrect
- 3 Unable to open the specified script or output file
- 4 One of the services used returned a failure
- 5 A command syntax error occurred. The script failed because an object was improperly selected or was invalid for use with that command
Availability
- External
-
- DOS
-
none
- Windows
-
none
- Windows NT
-
NTXP
NT2003
Last Updated: 2003/07/28
Direct corrections or suggestions to:
Rick Lively