Introduction to diskpart Command Line Utilities

Source: Internet
Author: User

Set focus command

Select

You can use the SELECT command to set the focus to the specified target. To obtain the focus type list, leave the type field blank. If no ID is specified, the current object in focus is displayed.

Select disk [= N]

You can use the select disk command to set the focus to a disk with the specified Windows NT disk number. If no disk number is specified, this command displays the current disk in focus.

Select partition [= N/L]

You can use the select partition command to set the focus to the specified partition. If no partition is specified, the current focus partition is displayed.

On a basic disk, you can specify partitions by index, drive letter, or mount point. On a dynamic disk, you can only specify partitions by index.

Select volume [= N/L]

You can use the select volume command to set the focus to the specified volume. If no volume is specified, this command displays the volume currently in focus.

You can specify a volume by index, drive letter, or mount point path. On a basic disk, if you select a volume, the corresponding partition also has a focus.
Command for displaying disk configurations

Use the LIST command to display the summary. To display more information, set the focus first and then use the detail command.

Detail Disk

Use the detail disk command to obtain detailed information about the current disk in focus, for example:
Diskpart> select Disk 3

Disk 3 is now the selected disk.

Diskpart> detail Disk

Maxtor 90432d2
Disk ID: f549d151
Type: ide
Bus: 0
Target: 0
Lun ID: 0

Volume ### LTR label FS type size status info
---------------------------------------------------------------------
Volume 0 f my raid Set NTFS raid-5 4096 MB healthy
Volume 1g fatstripe FAT32 stripe 6144 MB healthy
Volume 2 h my mirror NTFS mirror 2048 MB healthy
Volume 3 I my span NTFS spanned 9 GB healthy

Detail Partition

Use the detail partition command to obtain detailed information about the currently focused partition;
Diskpart> select disk 0

Disk 0 is now the selected disk.

Diskpart> select partition 1

Partition 1 is now the selected partition.

Diskpart> detail Partition

Partition 0
Type: 07
Hidden: No
Active: Yes

Volume ### LTR label FS type size status info
---------------------------------------------------------------
* Volume 2 c ntfs partition 4110 MB healthy System

Detail volume

Use the detail volume command to obtain detailed information about the volume currently in focus, for example:
Diskpart> select volume 1

Volume 1 is now the selected volume.

Diskpart> detail volume

Disk ### status Size Free Dyn GPT
--------------------------------------
Disk 1 online 8 GB 0 B *
Disk 2 online 8 GB 0 B *
Disk 3 online 8 GB 0 B *

List Disk

Use the list disk command to obtain summary information about each disk in the computer. A disk with an asterisk (*) has the current focus. This command only lists fixed disks (for example, integrated device circuits [Ide] or small computer system interfaces [SCSI]) or removable disks (for example, 1394 or USB ). The removable drive is not displayed.
Diskpart> select Disk 3

Disk 3 is now the selected disk.

Diskpart> List Disk

Disk ### status Size Free Dyn GPT
--------------------------------------
Disk 0 online 4118 MB 0 B
Disk 1 online 8 GB 4002 Mbit/s *
Disk 2 online 8 GB 0 B *
* Disk 3 online 8 GB 0 B *
Disk M0 missing 8 GB 0 B *

List Partition

You can use the list partition command to obtain information about each partition on the disk in focus, for example:
Diskpart> select disk 4

Disk 4 is now the selected disk.

Diskpart> List Partition

Partition ### type size offset
-------------------------------------------
Partition 1 primary 4094 MB 31 KB
Partition 2 extended 4581 MB 4094 MB
Partition 3 logical 2,047 MB 4,094 MB
Partition 4 logical 2533 MB 6142 MB

All partitions (regardless of type) are displayed.

List volume

Use the list volume command to obtain information about each volume on the computer, for example:
Diskpart> List volume

Volume ### LTR label FS type size status info
----------------------------------------------------------------------
Volume 0 f my raid Set NTFS raid-5 4096 MB healthy
Volume 1g fatstripe FAT32 strwipe 6144 MB failed
Volume 2 h my mirror NTFS mirror 2048 MB healthy
Volume 3 I my span NTFS spanned 9 GB healthy
Volume 4 d CDFs CD-ROM 0 B
Volume 5 c ntfs partition 2047 MB healthy System
Volume 6 e ntfs partition 2063 MB healthy boot
Volume 7 J my primary NTFS partition 4095 MB healthy
Volume 8 K my logical NTFS partition 2047 MB healthy
Volume 9 L my next log NTFS partition 2534 MB healthy

Commands for managing basic Disks

This section describes how to create and delete partitions and how to assign drive letters and mount points. The commands in this section only apply to basic disks. For commands for converting a basic disk to a dynamic disk, see the following sections.

On all MBR disks, the size or offset parameters are rounded to ensure cylindrical alignment. On a GPT disk, the size and offset parameters are also rounded to ensure the slice alignment. If the offset parameter is not specified, the partition is placed in the first sufficiently large range of continuous disks that are not occupied. If the size parameter is not listed, the partition can be extended to a specific disk occupation range, which can occupy the entire disk size at most.

When a new disk is first discovered, it is assumed as an MBR disk. Before creating a GPT partition, you must explicitly convert the disk to a GPT. We recommend that you create MSR as the first partition on each data disk and the second partition on any system or boot disk (after ESP ). After converting from MBR to GPT, MSR partitions are automatically created on the disk.

After creating any new partition, the recently created partition will get the partition focus. After deleting any partition, the partition focus will also be lost. The disk focus remains unchanged under any circumstances.

Active

You can use the active command to set the currently focused partition to "active ". This setting notifies the firmware that this partition is a valid system partition. Diskpart does not verify the partition content.

Note: If you use this command, you may not be able to restart the computer.

Assign [[letter = L]/[Mount = path] [noerr]

Use the assign command to assign a drive letter or mount point to the currently focused partition. If no drive letter is specified, the next available drive letter is assigned. If the drive letter or mount point is already in use, an error is generated unless the noerr parameter is used.

You can use this command to change the drive letter associated with the removable drive.

Do not assign drive letters to the system, Boot, or paging volumes. Except for the msdata partition, this command cannot be used to assign drive letters to an OEM partition or any GPT partition.

Create partition primary [size = N] [offset = N] [ID = byte/GUID] [noerr]

Use the create partition primary command to create a primary partition on the current drive at a certain length and starting address offset.

If no ID byte is specified on the MBR disk, this command uses the type "0x6" to create a partition. You can use the ID parameter to specify the partition type. Validation or other validation of ID bytes is not performed.

If the id guid is not specified on the GPT disk, this command creates the msdata partition. You can use the ID parameter to specify any guid. The GUID is not verified for validity, repeatability, or other purposes. The GUID of the partition sample is automatically generated.

Because the MBR and GPT partitions are created, the drive letter is not automatically assigned to Windows. You must explicitly assign a drive letter.

Create partition extended [size = N] [offset = N] [noerr]

Use the create partition extended command to create an extended partition on the current drive at a certain length and starting address offset. The drive must be an MBR disk.

After a partition is created, the new extended partition gets the focus. Only one extended partition can be created. You can only create a logical drive after creating an extended partition.

Create partition logical [size = N] [offset = N] [noerr]

Use the create partition logical command to create a logical drive in the existing extended partition of the current disk at a certain length and starting address offset. The drive must be an MBR disk.

If the offset is not listed, the logical drive will be placed in the first sufficiently large extended partition without occupying the continuous disk range. If the size is not listed, the partition may be extended to occupy the entire extended partition.

After a partition is created, the logical drive obtains the partition focus.

Create partition MSR [size = N] [offset = N] [noerr]

The create partition MSR command is equivalent to creating a partition using the MSR guid E3C9E316-0B5C-4DB8-817D-F92DF00215AE.

Create partition ESP [size = N] [offset = N] [noerr]

The create partition ESP command is equivalent to creating a partition using the ESP guid C12A7328-F81F-11D2-BA4B-00A0C93EC93B.

Delete partition [noerr] [override]

You can use the delete partition command to delete the currently focused partition.

Diskpart: Do not delete the current system, start, or paging volume. To delete an ESP, MSR, or known OEM partition, you must specify the override parameter.

Extend [size = N] [noerr]

You can use the Extend Command to extend the current focused volume to an unallocated continuous space. Unallocated space must be placed behind the focus partition (the sector offset of the former must be greater than that of the latter ). This command is used to increase the existing basic data partition to the Space recently created on the Scalable hardware raid logical unit number (Lun.

If you used the NTFS file system to format partitions, the file system will automatically expand to occupy larger partitions without data loss. If you have previously used any file system format other than NTFS to format the partition, this command fails without changing the partition.

Diskpart only disables expansion of the current system or startup partition.

Remove [[letter = L]/[Mount = path]/[all] [noerr]

Use the remove command to delete the drive letter or mount point of the currently focused partition. If the All parameter is specified, all current drive letters and mount points are deleted. If no drive letter or mount point is specified, the drive letter is deleted.

Use this command to change the drive letter associated with the removable drive.

The drive letter of the system, Boot, or paging volume cannot be deleted. You cannot use this command to transfer drive letters to OEM partitions, any GPT partitions with unrecognized guids, or any special non-data GPT partitions (such as ESP partitions ).
Command for managing dynamic Disks

You can use the commands described in this section to create and delete volumes, repair Fault Tolerant volumes, and import disks.

The size parameter must always be rounded to ensure the MB alignment. The explicit offset cannot be specified. This volume is always placed in the first sufficiently large non-occupied continuous disk range. If the size is not listed, create the volume as large as possible.

After a volume is created, the volume focus is placed on the recently created volume. If the volume spans multiple disks, the current disk focus will be lost. If you delete a volume, the volume focus is lost. If a valid disk focus exists before the volume is deleted, the disk focus is retained.

Note: When any blank disk is converted to a dynamic or GPT disk, diskpart forcibly creates an MSR partition on the converted disk.

Active

You can use the active command to set the volume currently in focus to "active ". This setting notifies the firmware that this partition is a valid system partition. Diskpart only verifies that this volume can contain an operating system boot image without verifying the partition content. If you use this command, the computer may not be restarted.

Add disk = N [noerr]

Use the Add command to add an image to the volume currently in focus on the specified disk. Only two image clusters are supported. The volume currently in focus must be a simple volume.

Assign [[letter = L]/[Mount = path] [noerr]

Use the assign command to assign a drive letter or mount point to the volume currently in focus. If no drive letter is specified, the next available drive letter is assigned. If the drive letter or mount point is already in use, an error is generated unless the noerr parameter is specified.

Do not assign drive letters to the system, Boot, or paging volumes.

Break disk = N [nokeep] [noerr]

Use the break command to disconnect an image that is currently in focus.

By default, the content of both image clusters will be retained because both of them have become simple volumes. If the nokeep parameter is specified, only the specified cluster is retained, and the other cluster is deleted and converted to idle space.

The original volume retains all drive letters or mount points. If the cluster is not retained, the focus remains on the simple volume on the specified disk. Otherwise, the focus is changed to the reserved cluster specified on the specified disk. This cluster becomes a simple volume; however, no drive letter is assigned to the new volume.

Create volume simple [size = N] [disk = N] [noerr]

Use the create volume simple command to create a simple volume with a certain length on the specified disk.

If the size is not specified, the new volume can occupy the remaining continuous free space on the disk. If no disk is specified, the current disk in focus is used.

After a volume is created, the disk focus is set to the target disk.

Create volume stripe [size = N] disk = N [, N [,...] [noerr]

Use the create volume stripe command to create a volume with a partition set on a specified disk. The total size of a zone volume is the product that the zone volume on each disk is multiplied by the number of disks.

If the size is not specified, create a zone volume as large as possible. The disk with the minimum continuous available free space is determined. The size of the free space determines the size of the zone volume. The size of the partition volume allocated to each disk is the same.

Create volume raid [size = N] disk = N [, N [,...] [noerr]

You can use the create volume raid command to create a raid-5 set volume on a specified disk. Each disk is allocated space equivalent to "Raid-5 volume size.

If the size is not specified, create a RAID 5 volume as large as possible. The disk with the minimum continuous available free space is determined. The size of the free space determines the size of the RAID 5 volume, and the size of the RAID 5 volume allocated from each disk is the same. The actual volume size is smaller than the size of the raid-5 volume on each disk multiplied by the number of disks, because some space is used for parity.

Delete disk [noerr] [override]

You can use the delete disk command to delete missing dynamic disks from the disk list.

If the override parameter is not specified, all simple volumes contained in the disk will be deleted, and all image clusters will be deleted. If the disk is used for RAID 5 volumes, this command fails.

Delete partition [noerr] [override]

You can use the delete partition command to delete the currently focused partition.

Diskpart: Do not delete any partitions that contain existing online dynamic volumes. However, these volumes must be deleted and converted to basic disks. To delete an ESP, MSR, or known OEM partition, you must specify the override parameter.

Partitions can be deleted from a dynamic disk, but they cannot be created. For example, you can delete a GPT partition that is not recognized on a dynamic GPT disk. If you delete a partition, the free space is unavailable. In an emergency where the clean command cannot be used, you can use this command to reclaim the space on the damaged offline dynamic disk.

Delete volume [noerr]

You can use the delete volume command to delete the volume currently in focus. After you use this command, all data is lost.

Extend disk = N [size = N] [noerr]

You can use the Extend Command to extend the current simple volume or extended volume to a specified disk. The Extend Command is only applicable to NTFS volumes.

If no size is specified, this volume can occupy all the free space on the specified disk. Any existing disk focus will be lost.

Import [noerr]

Use the import command to import all disks in the external disk group.

If focus is set on any disk in the external disk group, all disks in the group can be imported. After running this command, any existing volume or disk focus will be lost.

Online [noerr]

The online command can be used to bring offline disks or volumes online again. If you use this command, the focus will not change.

Remove [[letter = L]/[Mount = path]/[all] [noerr]

Use the remove command to delete the drive letter or mount point of the current volume in focus. If the All parameter is used, all the current drive letter and mount point will be deleted. If no drive letter or mount point is specified, the first path encountered is deleted.

The drive letter of the system, Boot, or paging volume cannot be deleted.

Retain

Use the retain command to prepare a dynamic simple volume as a start or system volume.

If you use the retain command on an x86 computer, a focused MBR partition will be created on a dynamic simple volume. To create an MBR partition, the dynamic simple volume must start from the offset of a cylindrical alignment, and its size must be an integer multiple of the cylindrical size.

If you use the retain command on an itanium-based computer, the retain command creates a focus GPT partition on a dynamic simple volume.
Disk conversion command

Convert MBR [noerr]

Use the convert MBR command to set the partition form of the current disk to MBR. A disk can be a basic disk or a dynamic disk, but cannot contain any valid data partition or volume.

Convert GPT [noerr]

Use the convert GPT command to set the partition form of the current disk to GPT. A disk can be a basic disk or a dynamic disk, but cannot contain any valid data partition or volume. This command is valid only on an itanium-based computer and may fail on a x-86-based computer.

Convert dynamic [noerr]

Use the convert dynamic command to change a basic disk to a dynamic disk. A disk can contain valid data partitions.

Convert basic [noerr]

You can use the convert basic command to convert an empty Dynamic Disk to a basic disk.
Other commands

Exit

Use the exit command to stop diskpart and return control to the operating system.

Clean [all]

You can use the clean command to clear the slice, delete the partition from the current disk in focus, or format the volume. By default, only the MBR or GPT partition information and any hidden sector information about the MBR disk are rewritten. If you specify the All parameter, you can clear each sector and delete all data contained in the drive.

Rem [...]

The REM command does not perform any operations, but you can use this command to annotate the script file.

Rescan

You can use the rescan command to rescan all I/O buses and discover any new disks added to your computer.
Help commands

Help

Use the HELP command to display the list of all commands.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.