About the Diskpart command line utility

This article will introduce you to the Diskpart utility. You can use this utility to set up a storage configuration using a script, a remote control session, or through a different command window. Diskpart helps enhance the graphical user interface of Disk Administrator.

This article will introduce you to the Diskpart utility.You can use this utility to set up a storage configuration using a script, a remote control session, or through a different command window.Diskpart helps enhance the graphical user interface of Disk Administrator.

Diskpart is different from many other command line utilities because it does not work in a single-line mode. Instead, after you launch the utility, the commands are read from standard input / output (I / O). You can direct these commands to hard drives, partitions, or partitions.

Script

Diskpart supports script activities. To initialize a Diskpart script, use the diskpart / s script.txt command. You can script Diskpart on Windows XP, Windows 2000, Remote Installation Services (RIS) or Windows Preinstall Environment (PE) installation environments for OEM.

By default, Diskpart can exit the command processing and return an error code if there is a problem in the script. To continue running the script in this case, include the noerr parameter in the command. This parameter allows you to use a single script to delete all partitions on all data drives, regardless of the total number of drives. However, not all commands support this parameter. Even if you use this parameter, sometimes it is possible to return the syntax errors of the command.

The list below describes the error codes for Diskpart:

  1. 0 - No error. The entire script has run without errors
  2. 1 - A fatal exception has appeared. May be a serious problem
  3. 2 - The topics specified on the Diskpart command line are incorrect
  4. 3 - Diskpart cannot open the specified script or output file
  5. 4 - One of the services that Diskpart uses fails
  6. 5 - A syntax error appears. The script failed because an inappropriate object was selected or invalid to use with that command.

After you run Diskpart, the Diskpart version and the name of the current computer will be displayed.

Commands to set Focus

select

Use select to set focus to the specified target. To get a list of focus types, leave the Type field blank. If you do not specify an ID number, the current focus object will be displayed.

select disk [= n]

Use the select disk command to set the focus to the drive that has the specified Windows NT drive number. If you do not specify a drive number, this command displays the current drive in focus.

select partition [= n / l]

Use this command to set the focus to the specified partition. If you do not specify a partition, the currently active partition is displayed.

On basic disks, you can specify the partition by using an index, drive letter, or mount point. You can only specify the partition by index on dynamic disks.

select volume [= n / l]

Use this command to set focus to the specified partition. If you do not specify a partition, this command will show the partition currently in focus (in-focus).

You can specify the partition by index (index), drive letter or mount point path. On a basic disk, if you select a partition, the corresponding partition will be placed in focus.

Commands to display the drive configuration

Use the list command to display the summary table. To display more details, set the focus, and then use the detail command.

detail disk

Use the detail disk command to obtain detailed information about the current in-focus drive, for example:

Diskpart> select disk 3

Đĩa 3 là ngay đĩa đã chọn

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 1 G 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 current in-focus partition;

Diskpart> select disk 0

Disk 0 là ngay đĩa đã chọn

Diskpart> select partition 1

Phân vùng 1 là ngay phân vùng đã chọn.

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 the current in-focus volume details, for example:

Diskpart> select volume 1

Số Volume 1 này hiện thời được chọn

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 the drives in the computer. The drive with an asterisk (*) has the current focus. Only fixed drives (for example, [IDE] or small computer system interface [SCSI]) or removable disk (for example, 1394 or USB) will be listed. Removable drives are not listed.

Diskpart> select disk 3

Đĩa 3 là ngay đĩa đã chọn

Diskpart> list disk


Disk ### Status Size Free Dyn Gpt
-------- ---------- ------- ------- --- ---
Disk 0 Online 4118 MB 0 B
Disk 1 Online 8 GB 4002 MB *
Disk 2 Online 8 GB 0 B *
* Disk 3 Online 8 GB 0 B *
Disk M0 Missing 8 GB 0 B *

list partition

Use the list partition command to obtain information about the partitions on the in-focus drive, for example:

Diskpart> select disk 4

Đĩa 4 là ngay đĩa đã chọn

Diskpart> list partition

Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 Primary 4094 MB 31 KB
Partition 2 Extended 4581 MB 4094 MB
Partition 3 Logical 2047 MB ​​4094 MB
Partition 4 Logical 2533 MB 6142 MB

Các phân vùng (bất thường của kiểu) được hiển thị

list volume

Use the list volume command to obtain information about volumes on your 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 1 G FATSTRIPE FAT32 Stripe 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

Basic disk management commands

This section will describe the commands that you can use to create and delete partitions, assign drive letters and mount points. The commands in this section apply only to basic disks. The next section will be commands for dynamic disks or commands you can use to convert basic disks to dynamic disks.

On all MBR drives, the size or offset parameters are aligned in cylinders, while on GPT drives these parameters are aligned according to sectors. If a parameter is not specified, the partition will be placed in the first contiguous contiguous disk area that is large enough. If the size parameter is not listed, the partition can be extended to occupy the defined drive area with the size of the entire drive.

After these new drives are first recognized, they are recognized as MBR drives. You must convert a drive to GPT before trying to create a GPT partition. You should create MSR as the first partition on each data drive and the second partition (after ESP) on any system or boot drive. After converting from MBR to GPT, the MSR partition is automatically created on the drive.

After you create a new partition, it will be the partition focus. After you delete any partition, the partition focus will be lost. Disk focus will remain the same in all cases.

active

Use the active command to set the current in-focus partition to "active." This setting declares the firmware (firmware) that this partition is valid for the system partition. Diskpart does not validate the contents of the partition.

Note : If you use this command, the computer may not restart

assign [[letter = l] / [mount = path]] [noerr]

Use the assign command to assign the character or point assigned to an existing in-focus partition. If you do not specify a drive letter, the next available drive letter will be assigned. If the character or mount point is already in use, an error will occur unless you use the noerr parameter.

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

Assigning a drive letter is locked on system, boot, or memory pages. This command cannot be used to assign a drive letter to an OEM partition or GPT partition, except the Msdata partition.

create primary partition [size = n] [offset = n] [id = byte / guid] [noerr]

Use the create partition primary command to create the primary partition for the size and address offset starting on the current drive.

If an ID byte is not specified on the MBR drive, this command creates a partition of type '0x6'. You can use the ID parameter to specify the partition type. There are no validations or checks for the ID byte.

If you do not specify an ID GUID on GPT disk, this command will create an Msdata partition. You can use the ID parameter to specify any GUID. There is no validity, doubling or checking the GUID. The Partition's immediate GUID is automatically created.

MBR and GPT partitions are created so that Windows does not automatically place drive letters. You must assign a clear drive letter.

tạo phân vùng mở rộng [size = n] [offset = n] [noerr]

Use the create partition extended command to create an extended partition for the long and offset addresses that start on the current drive. This drive must be an MBR drive.

After the partition is created, the new extended partition will be the focus. You can create just one extended partition. You can create logical drives only when you create an extended partition.

tạo hợp lệ phân vùng [kích cỡ = n] [offset = n] [noerr]

Use this command to create a logical drive for offset size and address starting in the existing extended partition on the current drive. Drive must be an MBR drive.

If an offset is not listed, the logical drive will be placed in the free contiguous contiguous disk area in the extended partition large enough. If the size is not listed, the partition can be expanded to occupy the entire extended partition.

After you create the partition, the logical drive will be the partition focus.

create msr partition [size = n] [offset = n] [noerr]

The create partition msr command is equivalent to creating an MSR partition GUID E3C9E316-0B5C-4DB8-817D-F92DF00215AE.

create partition esp [size = n] [offset = n] [noerr]

The create partition esp command is equivalent to creating the ESP partition GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B.

delete phân vùng [khôngerr] [override]

Use the delete partition command to delete the current in-focus partition.

Diskpart does not allow the current system, boot, or memory partition to be deleted. To delete ESP, MSR or OEM partition you must specify the override parameter.

extend [size = n] [noerr]

Use the extend command to convert the current in-focus volume that is expanded to an adjacent indefinite space. The unstable space must follow the in-focus partition (it must have a higher sector offset). This command is intended to develop an existing basic data partition into a newly created space on the extended hardware Raid logical unit number (LUN).

If the partition has been previously formatted as an NTFS file system, the file system will automatically be expanded to occupy the larger partition, the loss of data will not occur. If the partition was previously formatted as a file system format other than NTFS, the command will succeed and will not change the partition.

Diskpart blocks the extension of only the current system or boot partition.

remove [[letter = l] / [mount = path] / [all]] [noerr]

Use this command to remove characters or points from an existing in-focus partition. If you specify the all parameter, all the current drive letters and mount points will be removed. If you do not specify a character or mount point, the drive letter will be removed.

Use this command to change the drive letter for removable drives.

Removing drive letters is not done on system, boot, and memory pages. You cannot use this command to remove the drive letter for the OEM partition, any GPT partition with an unrecognized GUID, or any GPT partition that has no data such as the ESP partition.

Dynamic drive management commands (Dynamic)

You can use the commands described in this section to create and delete partitions, fix fault-tolerant partitions (meaning the ability to continuously non-stop when hardware occurs) and import drives. .

The size parameter is always aligned with MB. You cannot specify an offset. The partition is always placed in the first contiguous contiguous disk volume that is large enough. If the size is not listed, the largest partition will be created.

After a partition has been created, the volume focus will be placed on the newly created partition. The current disk focus will be lost if the volume extends to the drives. The volume focus may also be lost if a partition is deleted. If there is no valid disk focus before you delete the partition, that disk focus will remain.

Note : Diskpart requires creating an MSR partition on a blank disk when the drive is converted to a dynamic disk or GPT.

active

Use this command to set an existing in-focus partition to "active." This setting will declare the firmware part so that the partition will be a valid system partition. Diskpart will verify that the partition is capable of containing the operating system boot image but will not validate the contents of the partition. If you use this command, the computer may not be able to restart.

add disk = n [noerr]

Use this command to add a mirror to the current in-focus partition on the specified drive. Only two mirror plexes are supported here. The current in-focus partition must be a simple partition.

assign [[letter = l] / [mount = path]] [noerr]

Use this command to assign a character or a mount point to the current in-focus volume. If you do not specify a drive letter, the next available drive letter will be assigned to it. If the character or mount point is already in use, an error will appear here unless you specify the noerr parameter.

Assign a locked drive letter on system, boot and memory partitions.

break disk = n [nokeep] [noerr]

Use this command to stop the current in-focus mirror.

By default, the contents of both mirror plexes are retained because both plexes will become simple partitions. If you specify the nokeep parameter, only the specified plex will be retained and the other plex will be removed and converted to free space.

The root partition is retained and all drive letters or mount points. If the plex is not retained, the focus will remain on the single partition on a certain drive. Otherwise, the focus is changed to some retained plex on the specified drive. However, the plex becomes a single partition and the drive letter is not assigned to the new partition.

tạo kích cỡ simple [kích cỡ = n] [disk = n] [noerr]

Use the create volume simple command to create a single partition for the length size on the specified drive.

If you do not specify a size, the new partition can occupy the remaining free space remaining on the drive. If you do not specify a drive, the current in-focus drive will be used.

After the partition is created, the disk focus will give the target drive.

tạo kích cỡ khối [kích cỡ = n] đĩa = n [, n [, .]] [noerr]

Use the create volume stripe command to create a stripe volume on the specified drive. The overall size of the stripe partition is the size multiplied by the number of drives.

If you do not specify a size, the largest stripe volume will be created. The drive with the smallest available free space will be specified. The size of that free space indicates the size of the stripe partition. Such sizes are indicated on each drive.

tạo khối raid [size = n] disk = n [, n [, .]] [noerr]

Use the create volume raid command to create a Raid-5 partition on the specified drive. The amount of space is equal to the size specified on each drive.

If you do not specify a size, the largest partition will be created. The drive with the smallest contiguous free space will be specified. The size of that free space will specify the size of the Raid 5 partition and the same size is specified for each drive. The actual unusable size of the smaller size partition has been multiplied by the number of drives, since some of the space has already been used.

delete disk [noerr] [override]

Use the delete disk command to delete the dynamic disk that was not found from the drive list

If you do not specify a parameter, all the single partitions on the drive will be deleted and the mirror plex will also be removed.

delete phân vùng [khôngerr] [override]

Use the delete partition command to delete the current in-focus partition.

Diskpart does not allow the deletion of any partitions used to contain existing online dynamic partitions. Those partitions must be deleted and the drive converted to basic. To delete an ESP, MSR or OEM partition, you must specify the override parameter.

You can delete partitions from dynamic disks but cannot create them. For example, you can delete an unrecognized GPT partition on a dynamic GPT disk. If you delete a partition, the free space will not be available. You can use this command to recycle space on a corrupted offline dynamic disk in an emergency situation where you cannot use the clean command.

delete volume [noerr]

Use the delete volume command to delete the current in-focus partition. After using this command, all data will be lost.

extend disk = n [size = n] [noerr]

Use the extend command to expand the extended partition or the existing single partition on a specified drive. This command only works with NTFS partitions.

If you do not specify a size, this partition can occupy all free space of the specified drive. Any disk focus is lost.

import [noerr]

Use the import command to import all drives from the external disk group.

If you set a focus on the drives in the external drive group, you can import all the drives in the group. After you run this command, the existing partition or disk focus will be lost.

online [noerr]

Use the online command to bring an existing drive or partition before the offline status back online. Changes in focus do not occur if you use this command.

remove [[letter = l] / [mount = path] / [all]] [noerr]

Use this command to remove the character or mount point from the current in-focus partition. If you use the all parameter, all the current drive letters and mount points will be removed. If you do not specify a character or mount point, the path first encountered will be removed.

Removing this drive letter is not allowed on system, boot, and memory pages.

retain

Use the retain command to prepare a dynamic partition that will be used as a system partition or boot.

If you use this command on x86 computers, the MBR partition on the dynamic partition will be created with focus. To create an MBR partition, the dynamic partition must start at the cylinder with the offset address and be the integer of the cylinder by size.

If you use this command on Itanium computers, it will create a GPT partition on the dynamic partition with focus.

Drive conversion commands

convert mbr [noerr]

Use this command to set the partition size for the current drive to MBR. The drive may be a basic drive or a dynamic disk but must not contain valid data partitions or partitions.

convert gpt [noerr]

Use the convert gpt command to set the partition type of the current drive to GPT. The drive may be a basic disk or a dynamic disk but must not contain valid data partitions or partitions. This command is only valid on Itanium computers, it may not succeed on x86 computers.

convert dynamic [noerr]

Use the convert dynamic command to change a basic drive into a dynamic disk. This drive may include valid data partitions.

convert basic [noerr]

Use the convert basic command to change a blank dynamic disk to basic.

Other commands

exit

Use to stop Diskpart and return to operating the operating system

clean [all]

Use to remove the partition or partition being formatted from the current in-focus drive by deleting no sectors. By default, only MBR or GPT partition information and any hidden sector information on MBR drives will be overwritten. If you specify the all parameter, all sectors can be deleted and all data on the drive is deleted.

rem [.]

This command does nothing, you can use it to annotate script files.

rescan

Use this command to re-scan incoming / outgoing buses and detect new drives that have been added to the computer.

Help commands

help

Use this command to display a list of all commands.

4.1 ★ | 8 Vote | 👨 1989 Views
« PREV POST
NEXT POST »