Export (0) Print
Expand All

DiskPart Technical Reference (Standard 8)

7/8/2014

Review the use, syntax, location, options, and parameters for the DiskPart tool in Windows Embedded 8 Standard (Standard 8).

DiskPart is a text-mode command interpreter in Windows Embedded 8 Standard (Standard 8) that you use to manage objects, such as disks, partitions, or volumes by using scripts or direct input at a command prompt.

diskpart.exe
    active
    add
        disk=<n>
        [align=<n>]
        [wait]
        [noerr]
    assign
        [letter=<d> | mount=<path>]
        [noerr]
    attach
        [vdisk]
            [readonly]
            [sd=<sddl_string> | usefilesd]
            [noerr]
    attributes
        [disk]
            [set | clear]
            [readonly]
            [noerr]
        [volume]
            [set | clear]
            [hidden | readonly | nodefaultdriveletter | shadowcopy]
            [noerr]
    automount
        [enable | disable]
        [scrub]
        [noerr]
    break
        disk=<n>
        [nokeep]
        [noerr]
    clean
        [all]
    compact
        [vdisk]
    convert
        [basic | dynamic | gpt | mbr]
        [noerr]
    create
        [partition]
            [efi]
                [size=<n>]
                [offset=<n>]
                [noerr]
            [extended]
                [size=<n>]
                [offset=<n>]
                [align=<n>]
                [noerr]
            [logical]
                [size=<n>]
                [offset=<n>]
                [align=<n>]
                [noerr]
            [msr]
                [size=<n>]
                [offset=<n>]
                [noerr]
            [primary]
                [size=<n>]
                [offset=<n>]
                [id={<byte> | <guid>}]
                [align=<n>]
                [noerr]
        [volume]
            [raid]
                [size=<n>]
                disk=<n>,<n>,<n>[,<n>[,...]]
                [align=<n>]
                [noerr]
            [simple]
                [size=<n>]
                [disk=<n>]
                [align=<n>]
                [noerr]
            [stripe]
                [size=<n>]
                disk=<n>,<n>[,<n>[,...]]
                [align=<n>]
                [noerr]
            [mirror]
                [size=<n>]
                disk=<n>,<n>[,<n>[,...]]
                [align=<n>]
                [noerr]
        [vdisk]
            file=<"filename">
            {[type={fixed | expandable}] | [parent=<"filename">] | [source=<"filename">]}
            [maximum=<n>]
            [sd=<sddl_string>]
            [noerr]
    delete
        [disk]
            [noerr]
            [override]
        [partition]
            [noerr]
            [override]
        [volume]
            [noerr]
    detach
        [vdisk]
            [noerr]
    detail
        {disk | partition | volume | vdisk}
    exit
    expand
        [vdisk]
            maximum=<n>
    extend
        [[size=<n> | disk=<n>] | [filesystem]]
        [noerr]
    filesystems
    format
        [[fs={ntfs | fat | fat32 | udf}] [revision=<n.nn>] | [recommended]]
        [label=<"label">]
        [unit=<n>]
        [quick]
        [compress]
        [override]
        [duplicate]
        [nowait]
        [noerr]
    gpt
        attributes=<n>
    help | ?
        [<command>]
    import
        [noerr]
    inactive
    list
        [disk | partition | volume | vdisk]
    merge
        [vdisk]
            depth=<n>
    offline
        [disk | volume]
        [noerr]
    online
        [disk | volume]
        [noerr]
    recover
        [noerr]
    rem
    remove
        [letter=<d> | mount=<path> | all]
        [dismount]
        [noerr]
    repair
        disk=<n>
        [align=<n>]
        [noerr]
    rescan
    retain
    san
        [policy={onlineall | offlineall | offlineshared}]
        [noerr]
    select
        [disk={<n> | <disk_path> | system | next}]
        [partition=<n>]
        [volume={<n> | <d>}]
        [vdisk]
            file=<filename>
            [noerr]
    set
        id={<byte> | <guid>}
        [override]
        [noerr]
    shrink
        [desired=<n>]
        [minimum=<n>]
        [querymax]
        [nowait]
        [noerr]
    uniqueid
        [disk]
            [id={<dword> | <guid>}]
            [noerr]

You can find DiskPart under the %WINDIR%\System32\ folder. DiskPart is also included in a typical Windows Preinstallation Environment (Windows PE) 4.0 environment.

Before you can use DiskPart commands on a disk, partition, or volume, you must first list and then select the object to give it focus. When an object has the focus, any DiskPart commands that you type act on that object.

You can list the available objects and determine the number or drive letter of an object by using the list disk, list volume, and list partition commands. The list disk and list volume commands display all disks and volumes on the computer. However, the list partition command displays only partitions on the disk that have the focus. When you use the list commands, an asterisk (*) appears next to the object that has the focus. You select an object by its number or drive letter, such as disk 0, partition 1, volume 3, or volume C.

When you select an object, the focus remains on that object until you select a different object. For example, if the focus is set on disk 0, and you select volume 8 as on disk 2, the focus shifts from disk 0 to disk 2, volume 8. Some commands automatically change the focus. For example, when you create a new partition, the focus automatically changes to the new partition.

You can give focus only to a partition on the selected disk. When a partition has the focus, the related volume (if any) also has the focus. When a volume has the focus, the related disk and partition also have the focus if the volume maps to a single specific partition. If this is not the case, the focus on the disk and partition is lost.

JJ979618.note(en-us,WinEmbedded.81).gifNote:
When you use the DiskPart command as a part of a script, we recommend that you complete all the DiskPart operations together as part of a single DiskPart script. You can run consecutive DiskPart scripts. However, you must allow at least 15 seconds between each script for a complete shutdown of the previous execution before you run the DiskPart command again in successive scripts. Otherwise, the successive scripts might fail. You can add a pause between consecutive DiskPart scripts by adding the time-out /t 15 command to your batch file together with your DiskPart scripts.

For more information about how to use DiskPart in disk management, see this Microsoft Web site.

Command

Description

active

On basic disks, marks the partition that has the focus as active. This designation 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.

JJ979618.note(en-us,WinEmbedded.81).gifNote:
DiskPart verifies that only the partition can contain the startup files of an OS. DiskPart does not check the contents of the partition. If you mark a partition as active and it does not contain the startup files of the OS, your computer might not start.

add

Mirrors the simple volume that has the focus to the specified disk.

disk

Specifies a disk, other than the one containing the existing simple volume, 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.

align

Typically used with hardware RAID Logical Unit Number (LUN) arrays to improve performance. Aligns all volume or partition extents to the closest alignment boundary. <n> is the number of kilobytes (KB) from the beginning of the disk to the closest alignment boundary.

wait

Waits for the volume to finish synchronizing with the added disk before returning. Without the wait option, DiskPart returns after the mirrored volume is created and does not wait for the synchronization to complete.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

assign

Assigns a drive letter or mount point to the volume that has the focus. If no drive letter or mount point is specified, the next available drive letter is assigned. If the assigned drive letter or mount point is already being used, 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. You cannot assign a drive letter to an OEM partition or any GUID partition table (GPT) partition other than a basic data partition.

letter

Specifies the drive letter that you intend to assign to the volume.

mount

Specifies the mount-point path that you intend to assign to the volume.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

attach vdisk

Attaches (sometimes called "mounts" or "surfaces") a virtual hard disk (VHD) so that it appears on the host computer as a local hard disk drive. If the VHD already has a disk partition and file system volume when you attach it, the volume inside the VHD is assigned a drive letter.

readonly

Attaches the VHD as read-only. Any write operation returns an error.

sd= <sddl_string>

Sets the user filter on the VHD file. The filter string must be in the Security Descriptor Definition Language (SDDL) format. If you do not specify a security descriptor, the security descriptor from the parent directory is used.

SDDL strings can be complex but in its simplest form, a security descriptor that protects access is known as a discretionary access control list (DACL). It is of the form: D:<dacl_flags><string_ace1><string_ace2>...<string_aceN>

Common DACL flags are:

  • A – Allow access
  • D – Deny access

Common rights are:

  • GA – All access
  • GR – Read access
  • GW – Write access

Common user accounts are:

  • BA – Built-in administrators
  • AU – Authenticated users
  • CO – Creator owner
  • WD – Everyone

usefilesd

Specifies that the security descriptor on the .vhd file should be used on the VHD. If the usefilesd parameter is not specified, the VHD will not have an explicit security descriptor unless it is specified with the sd parameter.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

attributes disk

Displays, sets, or clears the attributes of a disk.

set

Sets the specified attribute on the selected disk.

clear

Clears the specified attribute from the selected disk.

readonly

Specifies that the disk is read-only.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

attributes volume

Displays, sets, or clears the attributes of a volume.

set

Sets the specified attribute on the selected volume.

clear

Clears the specified attribute from the selected volume.

hidden

Specifies that the volume is hidden.

readonly

Specifies that the volume is read-only.

nodefaultdriveletter

Specifies that the volume does not receive a drive letter by default.

shadowcopy

Specifies that the volume is a shadow-copy volume.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

automount

When it is enabled (the default), Standard 8 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 Standard 8 from automatically mounting or assigning drive letters to any new basic volumes added to the system.

enable

Enables Standard 8 to automatically mount new basic and dynamic volumes added to the system and to assign them drive letters.

disable

Prevents Standard 8 from automatically mounting any new basic and dynamic volumes that are added to the system.

scrub

Removes mounted folder path names, drive letters, mounted folder directories, 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.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

break

Applies to dynamic disks only. Breaks the mirrored volume that has the 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 that 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. If you use the nokeep parameter, only one-half of the mirror is retained as a simple volume, while the other half is deleted and converted to free space. Neither volume receives the focus.

disk= <n>

Specifies the disk that contains the mirrored volume. This disk is given focus and does not retain the drive letter or any mount points. If the specified disk is the current system or startup disk, the command fails.

nokeep

Specifies that only one copy of the mirrored volumes is retained. The other simple volume is deleted and converted to free space. Neither volume receives the focus.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

clean

Removes any partition or volume formatting from the disk that has the 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 is also overwritten. This includes the Protective MBR, which is overwritten. There is no hidden sector information.

all

Specifies that each and every sector on the disk is set to zero, which completely deletes all data contained on the disk.

compact vdisk

Reduces the physical size of a dynamically expanding virtual hard disk (VHD) file. This command is useful because dynamically expanding VHDs increase in size as you add files, but they do not automatically reduce in size when you delete files. You can only compact dynamically expanding VHDs that are detached or attached as read-only.

convert

Converts one disk type to another.

basic

Converts an empty dynamic disk to a basic disk.

JJ979618.note(en-us,WinEmbedded.81).gifImportant:
The disk must be empty to convert it to a basic disk. Back up your data, and then delete all partitions or volumes before converting the disk.

dynamic

Converts a basic disk into a dynamic disk. Any existing partitions on the basic disk become simple volumes.

gpt

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. The required minimum disk size for conversion to GPT is 128 megabytes.

JJ979618.note(en-us,WinEmbedded.81).gifImportant:
The disk must be empty to convert it into a GPT disk. Back up your data, and then delete all partitions or volumes before converting the disk.

mbr

Converts an empty basic disk with the GUID Partition Table (GPT) partition style into a basic disk with the master boot record (MBR) partition style.

JJ979618.note(en-us,WinEmbedded.81).gifImportant:
The disk must be empty to convert it into an MBR disk. Back up your data, and then delete all partitions or volumes before converting the disk.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

create partition efi

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 new partition gets the focus.

size= <n>

Specifies the size of the partition in megabytes (MB). If no size is given, the partition continues until there is no more free space in the current region.

offset= <n>

Specifies the byte offset at which to create the partition. If no offset is given, the partition is put in the first disk that is large enough to hold it.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

create partition extended

Creates an extended partition on the disk with focus. You can use this command only on Master Boot Record (MBR) disks. After the partition has been created, the focus automatically shifts to the new partition. You can create only one extended partition per disk. This command fails if you try to create an extended partition within another extended partition. You must create an extended partition before you can create logical drives.

size= <n>

Specifies the size of the extended partition in megabytes (MB). If no size is given, the partition continues until there is no more free space in the region.

offset= <n>

Specifies the offset in kilobytes (KB), at which the partition is created. If no offset is given, the partition will start at the beginning of the free space on the disk that is large enough to hold the new partition.

align= <n>

Aligns all partition extents to the closest alignment boundary. Typically used with hardware RAID (redundant array of independent disks) Logical Unit Number (LUN) arrays to improve performance. <n> is the number of kilobytes (KB) from the beginning of the disk to the closest alignment boundary.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

create partition logical

Creates a logical drive in the extended partition. You can use this command only on Master Boot Record (MBR) disks. After the partition has been created, the focus automatically shifts to the new logical drive.

size= <n>

Specifies the size of the extended partition in megabytes (MB). If no size is given, the partition continues until there is no more free space in the region.

offset= <n>

Specifies the offset in kilobytes (KB), at which the partition is created. The offset rounds up to completely fill whatever cylinder size is used. If no offset is given, then the partition is placed in the first disk extent that is large enough to hold it. The partition is at least as long in bytes as the number specified by size=<n>. If you specify a size for the logical partition, it must be smaller than the extended partition.

align= <n>

Aligns all partition extents to the closest alignment boundary. Typically used with hardware RAID (redundant array of independent disks) Logical Unit Number (LUN) arrays to improve performance. <n> is the number of kilobytes (KB) from the beginning of the disk to the closest alignment boundary.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

create partition msr

Creates a Microsoft reserved (MSR) partition on a GUID partition table (GPT) disk.

JJ979618.note(en-us,WinEmbedded.81).gifNote:
Be very careful when using this 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 boot the Windows operating system, the Extensible Firmware Interface (EFI) system partition is the first partition on the disk, followed by the Microsoft Reserved partition. GPT disks that are used only for data storage do not have an EFI system partition, in which case the Microsoft Reserved partition is the first partition.

Windows does not mount Microsoft Reserved partitions. You cannot store data on them and you cannot delete them.

A Microsoft Reserved partition is required on every GPT disk. The size of this partition depends on the total size of the GPT disk. The size of the GPT disk must be at least 32 MB to create a Microsoft Reserved partition.

size= <n>

Specifies the size of the extended partition in megabytes (MB). If no size is given, the partition continues until there is no more free space in the region.

offset= <n>

Specifies the offset in kilobytes (KB), at which the partition is created. The offset rounds up to completely fill whatever cylinder size is used. If no offset is given, then the partition is placed in the first disk extent that is large enough to hold it. The partition is at least as long in bytes as the number specified by size=<n>. If you specify a size for the logical partition, it must be smaller than the extended partition.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

create partition primary

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 the assign command to assign a drive letter to the partition.

size= <n>

Specifies the size of the extended partition in megabytes (MB). If no size is given, the partition continues until there is no more free space in the region.

offset= <n>

Specifies the offset in kilobytes (KB), at which the partition is created. The offset rounds up to completely fill whatever cylinder size is used. If no offset is given, then the partition is placed in the first disk extent that is large enough to hold it. The partition is at least as long in bytes as the number specified by size=<n>. If you specify a size for the logical partition, it must be smaller than the extended partition.

id={ <byte> | <guid> }

Specifies the partition type. This parameter is intended for original equipment manufacturer (OEM) use only. Any partition type byte or GUID can be specified with this parameter. DiskPart does not check the partition type for validity except to ensure that it is a byte in hexadecimal form or a GUID.

JJ979618.Caution(en-us,WinEmbedded.81).gifCaution:
Creating partitions with this parameter might cause your computer to fail or be unable to start up. Unless you are an OEM or an IT professional experienced with GUID partition table (GPT) disks, do not create partitions on GPT disks using this parameter. Instead, always use the create partition efi command to create Extensible Firmware Interface (EFI) system partitions, the create partition msr command to create Microsoft Reserved (MSR) partitions, and the create partition primary command (without the id parameter) to create primary partitions on GPT disks.

Master boot record disks

For master boot record (MBR) disks, you specify a partition type byte, in hexadecimal form, for the partition. If this parameter is not specified for an MBR disk, the command creates a partition of type 0x06, which specifies that a file system is not installed. Examples include:

  • LDM data partition: 0x42
  • Recovery partition: 0x27
  • Recognized OEM partition: 0x12, 0x84, 0xDE, 0xFE, 0xA0

GUID partition table disks

For GUID partition table (GPT) disks, you can specify a partition type GUID for the partition that you want to create. Recognized GUIDs include:

  • EFI system partition: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
  • Microsoft Reserved partition: e3c9e316-0b5c-4db8-817d-f92df00215ae
  • Basic data 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
  • Recovery partition: de94bba4-06d1-4d40-a16a-bfd50179d6ac

If this parameter is not specified for a GPT disk, the command creates a basic data partition.

align= <n>

Aligns all partition extents to the closest alignment boundary. Typically used with hardware RAID (redundant array of independent disks) Logical Unit Number (LUN) arrays to improve performance. <n> is the number of kilobytes (KB) from the beginning of the disk to the closest alignment boundary.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

create volume raid

Creates a RAID-5 volume on three or more specified dynamic disks. After you create the volume, the focus automatically shifts to the new volume.

size= <n>

Specifies the disk space, in megabytes (MB), that the volume occupies on each disk. If no size is given, the largest possible RAID-5 volume is created. The disk that has the smallest available contiguous free space determines the size for the RAID-5 volume, and the same amount of space is allocated from each disk. The actual amount of usable disk space in the RAID-5 volume is less than the combined amount of disk space because some disk space is required for parity.

disk= <n> , <n> , <n> [, <n> ,...]

Specifies the dynamic disks on which to create the RAID-5 volume. You must have at least three dynamic disks to create a RAID-5 volume. An amount of space equal to size=<n> is allocated on each disk.

align= <n>

Aligns all partition extents to the closest alignment boundary. Typically used with hardware RAID (redundant array of independent disks) Logical Unit Number (LUN) arrays to improve performance. <n> is the number of kilobytes (KB) from the beginning of the disk to the closest alignment boundary.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

create volume simple

Creates a simple volume. After you create the volume, the focus automatically shifts to the new volume.

size= <n>

Specifies the size of the volume in megabytes (MB). If no size is given, the new volume uses the remaining free space on the disk.

disk= <n>

Specifies the dynamic disk on which to create the volume. If no disk is given, the current disk is used.

align= <n>

Aligns all partition extents to the closest alignment boundary. Typically used with hardware RAID (redundant array of independent disks) Logical Unit Number (LUN) arrays to improve performance. <n> is the number of kilobytes (KB) from the beginning of the disk to the closest alignment boundary.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

create volume stripe

Creates a striped volume by using two or more specified dynamic disks. After you create the volume, the focus automatically shifts to the new volume.

size= <n>

Specifies the disk space, in megabytes (MB), that the volume occupies on each disk. If no size is given, the new volume uses the remaining free space on the smallest disk and an equal amount of space on each subsequent disk.

disk= <n> , <n> [, <n> ,...]

Specifies the dynamic disks on which to create the striped volume. You must have at least two dynamic disks to create a striped volume. An amount of space equal to size=<n> is allocated on each disk.

align= <n>

Aligns all partition extents to the closest alignment boundary. Typically used with hardware RAID (redundant array of independent disks) Logical Unit Number (LUN) arrays to improve performance. <n> is the number of kilobytes (KB) from the beginning of the disk to the closest alignment boundary.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

create volume mirror

Creates a volume mirror by using the two specified dynamic disks. After you create the volume, the focus automatically shifts to the new volume.

size= <n>

Specifies the disk space, in megabytes (MB), that the volume occupies on each disk. If no size is given, the new volume uses the remaining free space on the smallest disk and an equal amount of space on each subsequent disk.

disk= <n> , <n> [, <n> ,...]

Specifies the dynamic disks on which to create the mirror volume. You must have at least two dynamic disks to create a mirror volume. An amount of space equal to size=<n> is allocated on each disk.

align= <n>

Aligns all partition extents to the closest alignment boundary. Typically used with hardware RAID (redundant array of independent disks) Logical Unit Number (LUN) arrays to improve performance. <n> is the number of kilobytes (KB) from the beginning of the disk to the closest alignment boundary.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

create vdisk

Creates a new virtual hard disk (VHD) file by using the available disk space on the computer, and then saves it to the location that you specify. When you first create a VHD, it is similar to an uninitialized hard disk drive. You can then create one or more partitions in the VHD and format the partition(s) by using FAT, ExFAT, or NTFS. You can create three types of VHDs:

  • Fixed-size VHDs. A fixed VHD has an allocated size that does not change. To create a fixed VHD, use the type=fixed parameter.
  • Dynamically expanding VHDs. A dynamically expanding VHD resizes to accommodate the data that it contains. To create a dynamically expanding VHD, use the type=expandable parameter.
  • Differencing VHDs. A differencing VHD is similar to a dynamically expanding VHD, but it contains only the modified disk blocks of the associated parent VHD. To create a differencing VHD, use the parent parameter.

file= <filename>

Specifies the full path and file name of the VHD file to create. If type, parent, or source is not specified, a fixed VHD is created. The file path can be to a network share.

type={ fixed | expandable }

Specifies one of the following parameters:

  • Fixed (default): Creates a fixed VHD, which has an allocated size that does not change. For example, if you create a fixed VHD that is 24 gigabytes (GB), the file will be approximately 24 GB (with some space used for the internal VHD structure) regardless of the data that is written to it. Creating a fixed VHD takes longer than creating an expandable VHD because the entire file is allocated at the time it is created.
  • Expandable: Creates a dynamically expanding VHD, which expands to accommodate the data that it contains. For example, a 24 GB dynamically expanding VHD is initially around 80 megabytes (MB) on the host file system. As data is written to the VHD, the file grows, but it has a maximum size of 24 GB.

parent= <filename>

Specifies to create a differencing VHD file that is a child of the parent VHD at the location specified by <filename>. The differencing VHD contains only the changes from the parent VHD. The parent can be any type of VHD (fixed, dynamically expanding, or differencing). The parent VHD is read-only, so you must modify the differencing VHD. When you use this parameter to create a differencing VHD, you cannot specify the type parameter. This is because the differencing VHD file always uses the type from the parent VHD.

source= <filename>

Specifies to create a new VHD file that is a copy of the source file at the location specified by <filename>. Note that there is no parent-child relationship established between the new VHD and the source VHD.

maximum= <n>

The maximum amount of space that is exposed by the VHD file in megabytes (MB). You should only specify maximum when you are creating a fixed or dynamically expanding VHD file.

sd= <sddl_string>

Sets the user filter on the VHD file. The filter string must be in the Security Descriptor Definition Language (SDDL) format. If you do not specify a security descriptor, the security descriptor from the parent directory is used.

SDDL strings can be complex but in its simplest form, a security descriptor that protects access is known as a discretionary access control list (DACL). It is of the form: D:<dacl_flags><string_ace1><string_ace2>...<string_aceN>

Common DACL flags are:

  • A – Allow access
  • D – Deny access

Common rights are:

  • GA – All access
  • GR – Read access
  • GW – Write access

Common user accounts are:

  • BA – Built-in administrators
  • AU – Authenticated users
  • CO – Creator owner
  • WD – Everyone

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

delete disk

Deletes a missing dynamic disk from the disk list.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

override

Enables DiskPart to delete 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.

delete partition

On a basic disk, deletes the partition that has the focus. You cannot delete the system partition, boot partition, or any partition that contains the active paging file or crash dump (memory dump).

JJ979618.Caution(en-us,WinEmbedded.81).gifCaution:
Deleting a partition on a dynamic disk can delete all dynamic volumes on the disk, thereby destroying any data and leaving the disk in a corrupted state. To delete a dynamic volume, always use the delete volume command instead.

You can delete partitions from dynamic disks. However, you must not create them. For example, you can delete an unrecognized GUID partition table (GPT) partition on a dynamic GPT disk. However, deleting such a partition does not cause the resulting free space to become available. This command is intended to enable space reclamation on a corrupted, offline dynamic disk in an emergency where the clean command cannot be used.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

override

Enables DiskPart to delete any partition regardless of type. Usually, DiskPart enables you to delete only known data partitions.

delete volume

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).

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

detach vdisk

Stops the selected virtual hard disk (VHD) from appearing as a local hard disk drive on the host computer. When a VHD is detached, you can copy it to other locations.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

detail

Displays the properties of the selected disk, partition, volume, or virtual hard disk (VHD). In the case of the detail volume command, displays the disks on which the volume resides, although volume details are not applicable to read-only volumes, such as a DVD-ROM or CD-ROM drive.

exit

Exits the DiskPart command interpreter.

expand vdisk

Expands a virtual hard disk (VHD) to the size that you specify. A VHD must be selected and detached for this operation to succeed.

maximum= <n>

Specifies the new size for the VHD in megabytes (MB).

extend

Extends the volume that has the focus into the next contiguous unallocated space. For basic volumes, the unallocated space must be on the same disk as, and must follow (have a larger sector offset number than), the partition that has the focus. A dynamic, simple, or spanned volume can be extended to any empty area on any dynamic disk. By 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 without a change to the partition.

You cannot extend the current system or boot partitions.

filesystem

Extends the file system of the volume that has focus to cover the entire volume. For use only on volumes where the file system was not extended with the volume.

size= <n>

Specifies the space, in megabytes (MB), to add to the current partition. If you do not specify a size, the disk is extended to use all the next contiguous unallocated space.

disk= <n>

Specifies the dynamic disk on which to extend the volume. An amount of space equal to size=<n> is allocated on the disk. If no disk is specified, the volume is extended on the current disk.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

filesystems

Displays information about the current file system of the volume with focus and lists the file systems that are supported for formatting the volume.

format

Formats the selected partition or volume with focus for use with Windows.

fs={ ntfs | fat | fat32 | udf }

Specifies the type of file system. If no file system is specified, the default file system is used. To view the default file system, run the filesystems command.

revision= <n.nn>

Specifies the file system revision (if applicable).

recommended

If a recommended file system exists, DiskPart uses that file system and revision instead of the default file system and revision. To view the recommended file system (if one exists), run the filesystems command.

label= <"label">

Specifies the volume label.

unit= <n>

Overrides the default allocation unit size. Default settings are strongly recommended for general use. To view the default allocation unit size for each file system that is supported by the volume, run the filesystems command. Note that NTFS compression is not supported for allocation unit sizes above 4096.

quick

Performs a quick format.

compress

This parameter only applies to volumes that will be formatted with the NTFS file system. When you use this command, files created on the new volume are compressed by default.

override

Forces the volume to dismount first if necessary. If the volume is forcefully dismounted, some open handles (files in use by an application) to that volume can become invalid.

duplicate

This parameter applies only to the universal disk format (UDF), revision 2.50 and above, for use with CD-RW media and hard drives. When this parameter is used, DiskPart duplicates the file system metadata on a second set of sectors on the disk. The duplicate metadata can be used by applications (for example repair or recovery applications) if the primary metadata sectors become corrupt.

nowait

Specifies to return the format immediately while the operation is still in progress. If this parameter is not specified, DiskPart prints out formatting progress in percentage.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

gpt

On basic GPT disks, assigns the GUID partition table (GPT) attribute(s) to the partition that has the focus. GPT partition attributes give additional information about how to use the partition. Some attributes are specific to the partition type GUID.

JJ979618.note(en-us,WinEmbedded.81).gifNote:
Changing the GPT attributes could cause basic data volumes to be unmountable or not be assigned drive letters. Unless you are an OEM or an IT professional experienced with GPT disks, do not change GPT attributes.

attributes= <n>

The hexadecimal that applies to the attribute that you intend to apply to the partition that has the focus. The GPT attribute field is a 64-bit field that contains two subfields. The larger field is interpreted only in the context of the partition ID, while the earlier field is common to all partition IDs.

All partitions have the following attribute:

  • 0x000000000000001 marks the partition as required and indicates to all disk-management tools that the partition must not be deleted. The Extensible Firmware Interface (EFI) system partition contains only those binaries necessary to start the OS, which makes it easy for OEM-specific or OS-specific binaries to be put in other partitions.

For basic data partitions, the following attribute is defined:

  • 0x8000000000000000 prevents the partition from having a drive letter automatically assigned. By default, each partition is assigned a new drive letter. Setting this attribute guarantees that, when a disk is moved to a new computer, a new drive letter is not automatically generated. Instead, the user can manually assign drive letters.

Other attributes can be added at any time and can include:

  • 0x4000000000000000 hides a partition's volume.
  • 0x2000000000000000 specifies the partition is a shadow copy of another partition.
  • 0x1000000000000000 specifies the partition is read-only.

help

Displays a list of available commands. Use with the name of a command for detailed information about that command.

import

Imports a foreign-disk group into the local computer's disk group. The import command imports every disk that is in the same group as the disk that has the focus.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

inactive

On basic master boot record (MBR) disks, marks the system partition or boot partition that has the focus as inactive. The computer starts from the next option that is specified in the BIOS, such as the CD drive or a Pre-Boot Execution Environment (PXE)-based boot environment (such as Remote Installation Services (RIS)), when you restart the computer.

JJ979618.note(en-us,WinEmbedded.81).gifNote:
Your computer might not start without an active partition. Do not mark a system or boot partition as inactive unless you are an experienced user who has a thorough understanding of the Windows operating system.

list

Displays a list of disks, of partitions in a disk, of volumes in a disk, or of virtual hard disks (VHDs).

disk

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 the focus. If a disk is missing, its disk number is prefixed with M. For example, the first missing disk is numbered M0.

partition

Displays the partitions listed in the partition table of the current disk. On dynamic disks, these partitions might not correspond to the dynamic volumes on the disk. This difference occurs because dynamic disks contain entries in the partition table for the system volume or boot volume (if present on the disk). Dynamic disks also contain a partition that occupies the rest of the disk and reserves space for use by dynamic volumes.

volume

Displays a list of basic and dynamic volumes on all disks.

vdisk

Displays a list of the VHDs that are attached and/or selected. This command lists detached VHDs if they are currently selected; however, the disk type is set to Unknown until the VHD is attached. The VHD marked with an asterisk (*) has focus.

merge vdisk

Merges a differencing virtual hard disk (VHD) with its corresponding parent VHD. The parent VHD will be modified to include the modifications from the differencing VHD and, as a result, other differencing VHDs that are dependent on the parent will no longer be valid. A VHD must be selected and detached for this operation to succeed.

depth= <n>

Indicates the number of parent VHD files to merge together. For example, depth=1 indicates that the differencing VHD will be merged with one level of the differencing chain.

offline

Takes an online disk or volume to the offline state

disk

Changes the state of the selected disk in a storage area network (SAN) from online to offline. If a dynamic disk in a disk group is taken offline, the status of the disk changes to missing and the group shows a disk that is offline. The missing disk is moved to the invalid group. If the dynamic disk is the last disk in the group, then the status of the disk changes to offline, and the empty group is removed.

volume

Takes the online volume with focus to the offline state.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

online

Takes an offline disk or volume to the online state.

disk

Brings disks that are currently offline to an online state. If the group of a selected disk contains mirrored or RAID-5 volumes, this command also resynchronizes these volumes.

  • For basic disks, this command will attempt to bring online the selected disk and all volumes on that disk.
  • For dynamic disks, this command will attempt to bring online all disks that are not marked as foreign on the local computer. It will also attempt to bring online all volumes on the set of dynamic disks.
  • If a dynamic disk in a disk group is brought online and it is the only disk in the group, then the original group is recreated and the disk is moved to that group. If there are other disks in the group and they are online, then the disk is simply added back into the group.
JJ979618.note(en-us,WinEmbedded.81).gifImportant:
This command will fail if it is used on a read-only disk.

volume

Brings volumes that are currently offline to an online state. This command operates on volumes that have failed, are failing, or are in failed redundancy state.

JJ979618.note(en-us,WinEmbedded.81).gifImportant:
This command will fail if it is used on a read-only volume.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

recover

Refreshes the state of all disks in a disk group, attempt to recover disks in an invalid disk group, and resynchronizes mirrored volumes and RAID-5 volumes that have stale data. This command operates on disks that are failed or failing. It also operates on volumes that are failed, failing, or in failed redundancy state. This command applies only to groups of dynamic disks. If this command is used on a group with a basic disk, it will not return an error but no action will be taken.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

rem

Provides a way to add comments to a script. Place at the beginning of a line to have that line ignored when the script is run.

remove

Removes a drive letter or mount point from the volume that has the focus. If the all parameter is used, all current drive letters and mount points are removed. If you do not specify a drive letter or mount point, DiskPart removes the first drive letter or mount point that it encounters.

You can use the remove command 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 GUID partition table (GPT) partition with an unrecognized GUID, or any of the special, non-data, GPT partitions such as the Extensible Firmware Interface (EFI) system partition.

letter= <d>

Specifies the drive letter to remove.

mount= <path>

Specifies the mount point path of the remove command.

all

Removes all current drive letters and mount points.

dismount

Dismounts the 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, DiskPart closes any open handles before dismounting the volume. You can make the volume mountable by assigning it a drive letter or by creating a mount point path to the volume. The dismount parameter fails if you use it on a volume that has any remaining drive letters or mount points. For scripting, we recommend that you use remove all dismount.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

repair

Repairs the RAID-5 volume that has the focus by replacing the failed RAID-5 member with the specified dynamic disk. The specified dynamic disk must have free space larger than or equal to the total size of the failed RAID-5 member.

disk= <n>

Specifies the dynamic disk that replaces the failed RAID-5 member. The specified disk must have free space equal to or larger than the total size of the failed RAID-5 member.

align= <n>

Typically used with hardware RAID Logical Unit Number (LUN) arrays to improve performance. Aligns all volume or partition extents to the closest alignment boundary. <n> is the number of kilobytes (KB) from the beginning of the disk to the closest alignment boundary.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

rescan

Locates new disks that might have been added to the computer.

retain

Prepares an existing dynamic simple volume to use as a boot or system volume.

On a master boot record (MBR) dynamic disk, this command creates a partition entry in the master boot record.

On a GUID partition table (GPT) dynamic disk, this command creates a partition entry in the GUID partition table.

JJ979618.note(en-us,WinEmbedded.81).gifNote:
The retain command is intended for use only during unattended setup or by OEMs.

san

Displays or sets the storage area network (SAN) policy for the operating system. If the command is given with no parameters, the current SAN policy is displayed.

policy={ onlineall | offlineall | offlineshared }

Sets the SAN policy for the currently booted operating system. The SAN policy determines whether a newly discovered disk is brought online or remains offline, and whether it becomes read/write or remains read-only. When a disk is offline, the disk layout can be read, but no volume devices are surfaced through Plug and Play. This means that no file system can be mounted on the disk. When a disk is online, one or more volume devices are installed for the disk. The following is an explanation of each parameter:

  • OnlineAll. Specifies that all newly discovered disks will be brought online and made read/write.
    JJ979618.note(en-us,WinEmbedded.81).gifImportant:
    Specifying OnlineAll on a server that shares disks could lead to data corruption. Therefore, you should not set this policy if disks are shared among servers unless the server is part of a cluster.
  • OfflineAll. Specifies that all newly discovered disks except the boot disk will be offline and read-only by default.
  • OfflineShared. Specifies that all newly discovered disks that do not reside on a shared bus (such as SCSI and iSCSI) are brought online and made read-write. Disks that are left offline will be read-only by default.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

select disk

Selects the specified disk and shifts the focus to it.

<n>

Specifies the number of the disk to receive focus. You can view the numbers for all the disks on the computer by using the list disk command.

JJ979618.note(en-us,WinEmbedded.81).gifNote:
When configuring systems with multiple disks, do not use select disk=0 to specify the system disk. The computer may reassign disk numbers when you reboot, and different computers with the same disk configuration can have different disk numbers.

<disk_path>

Specifies the location of the disk to receive focus, for example, PCIROOT(0)#PCI(0F02)#ATA(C00T00L00). To view the location path of a disk, select it and then use the detail disk command.

system

On BIOS computers, specifies that disk 0 receives focus. On Extensible Firmware Interface (EFI) computers, the disk containing the EFI system partition (ESP) that is used for the current boot receives focus. On EFI computers, the command will fail if there is no ESP, if there is more than one ESP, or the computer is booted from Windows Preinstallation Environment (Windows PE).

next

Once a disk is selected, this command iterates over all disks in the disk list. When you run this command, the next disk in the list receives focus.

select partition

Selects the specified partition and shifts the focus to it. Before you can select a partition you must first select a disk using the select disk command. If a volume is selected with a corresponding partition, the partition will be automatically selected. If a partition is selected with a corresponding volume, the volume will be automatically selected. If no partition number is specified, this command displays the partition that currently has the focus in the selected disk.

<n>

The number of the partition to receive the focus. You can view the numbers for all partitions on the disk currently selected by using the list partition command.

select volume

Selects the specified volume and shifts the focus to it. On a basic disk, selecting a volume also gives the focus to the corresponding partition. If a volume is selected with a corresponding partition, the partition will be automatically selected. If a partition is selected with a corresponding volume, the volume will be automatically selected. If no volume is specified, this command displays the volume that currently has the focus in the selected disk.

<n>

The number of the volume to receive the focus. You can view the numbers for all volumes on the disk currently selected by using the list volume command.

<d>

The drive letter or mount point path of the volume to receive the focus.

select vdisk

Selects the specified virtual hard disk (VHD) and shifts the focus to it.

file= <filename>

Specifies the full path and file name of an existing VHD file.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

set

Changes the partition type field for the partition with focus. DiskPart does not check the validity of the value you specify except to ensure that it is a byte in hexadecimal form or a GUID. This command does not work on dynamic disks or on Microsoft Reserved partitions.

JJ979618.note(en-us,WinEmbedded.81).gifImportant:
This command is intended for use by original equipment manufacturers (OEMs) only. Changing partition type fields with this parameter might cause your computer to fail or be unable to boot. Unless you are an OEM or experienced with GUID partition table (GPT) disks, you should not change partition type fields on GPT disks by using this parameter. Instead, always use the create partition efi command to create Extensible Firmware Interface system partitions, the create partition msr command to create Microsoft Reserved partitions, and the create partition primary command without the id parameter to create primary partitions on GPT disks.

<btye>

For master boot record (MBR) disks, specifies the new value for the type field, in hexadecimal form, for the partition. Any partition type byte can be specified with this parameter except for type 0x42, which specifies an LDM partition. Note that the leading "0x" is omitted when specifying the hexadecimal partition type.

<GUID>

For GUID partition table (GPT) disks, specifies the new GUID value for the type field for the partition. Recognized GUIDs include:

  • EFI system partition: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
  • Basic data partition: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7

Any partition type GUID can be specified with this parameter except the following:

  • Microsoft Reserved partition: e3c9e316-0b5c-4db8-817d-f92df00215ae
  • LDM metadata partition on a dynamic disk: 5808c8aa-7e8f-42e0-85d2-e1e90434cfb3
  • LDM data partition on a dynamic disk: af9b60a0-1431-4f62-bc68-3311714a69ad
  • Cluster metadata partition: db97dba9-0840-4bae-97f0-ffb9a327c7e1

override

Forces the file system on the volume to dismount before changing the partition type. When you run the set command, DiskPart attempts to lock and dismount the file system on the volume. If override is not specified, and the call to lock the file system fails (for example, because there is an open handle), the operation will fail. When override is specified, DiskPart forces the dismount even if the call to lock the file system fails, and any open handles to the volume will become invalid.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

shrink

Reduces the size of the selected volume by the amount you specify. If neither a minimum amount nor a desired amount is specified, the volume will be reduced by as much as possible. You can reduce the size of a volume only if it is formatted using the NTFS file system or if it does not have a file system. This command makes free disk space available from the unused space at the end of the volume. This command works on basic volumes, and on simple or spanned dynamic volumes. This command does not operate on original equipment manufacturer (OEM) partitions, Extensible Firmware Interface (EFI) system partitions, or recovery partitions.

desired= <n>

Specifies the desired amount of space in megabytes (MB) to reduce the size of the volume by. If a desired amount is not specified, the volume will be reduced by the minimum amount (if specified).

minimum= <n>

Specifies the minimum amount of space in MB to reduce the size of the volume by. If there is not enough free space available to shrink the volume by the specified minimum amount, the command will fail. If a minimum amount is not specified, the volume will be reduced by the desired amount (if specified).

nowait

Specifies to return the process immediately while the operation is still in progress.

querymax

Returns the maximum amount of space in MB by which the volume can be reduced. This value may change if applications are currently accessing the volume. This parameter should only be used alone, or with the noerr parameter if desired.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

uniqueid disk

Displays or sets the GUID partition table (GPT) identifier or master boot record (MBR) signature for the disk with focus. This command works on basic and dynamic disks.

id={ <dword> | <guid> }

For MBR disks, specifies a four-byte (DWORD) value in hexadecimal form for the signature.

For GPT disks, specifies a GUID for the identifier.

noerr

For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerr option, an error causes DiskPart to exit with an error code.

By using the DiskPart command-line tool, you can create scripts to automate disk-related tasks, such as creating volumes or converting disks to dynamic disks. Scripting these tasks is useful if you deploy Standard 7 by using Image Builder in unattended mode or when you use the Sysprep tool, as neither of those methods support creating volumes other than the boot volume.

To start a DiskPart script, at the command prompt, type the following:

diskpart /s <scriptname.txt>

where <scriptname.txt> is the name of the text file that contains your script.

To redirect the DiskPart scripting output to a file, type the following:

diskpart /s <scriptname.txt> > <logfile.txt>

Where <logfile.txt> is the name of the text file where DiskPart writes its output.

When DiskPart starts, the DiskPart version and computer name display at the command prompt. By default, if DiskPart encounters an error when it tries to perform a scripted task, DiskPart stops processing the script and displays an error code (unless you specified the noerr parameter). However, DiskPart always returns errors when it encounters syntax errors, regardless of whether you used the noerr parameter. The noerr parameter enables you to perform useful tasks such as using a single script to delete all partitions on all disks regardless of the total number of disks.

The following table lists the DiskPart error codes.

Error

Description

0

No errors occurred. The script ran successfully.

1

A fatal exception occurred. There might be a serious problem.

2

The parameters that were specified for a DiskPart command are incorrect.

3

DiskPart was unable to open the specified script or output file.

4

One of the services that DiskPart uses returned an error.

5

A command syntax error occurred. The script did not complete because an object was incorrectly selected or was invalid for use with that command.

Show:
© 2014 Microsoft