วันจันทร์ที่ 29 กันยายน พ.ศ. 2557

A-Z of the Windows diskpart commands and parameters


 


Disk, Drive and Partition tools

2. Basic Windows diskpart and history 3. A-Z of the Windows diskpart command  and parameters

A-Z of the Windows diskpart commands and parameters

คำสั่ง และค่า Parameters ของ diskpart เรียงจาก A ถึง Z



A-Z of the Windows diskpart commands and parameters



ในหน้านี้จะมีตารางคำสั่ง และค่า Parameters ที่ใช้กับ Diskpart เท่านั้น สำหรับเนื้อหาที่เกี่ยวข้องอื่นให้คุณคลิกอ่านได้ตาม Link ด้านบน และด้านล่างของ Webpage

 

 





ถ้าคุณต้องการดูคำสั่งแบบย่อ ก็สามารถทำได้โดยการ เปิดโปรแกรม Diskpart > พิมพ์ Help จากนั้นกด Enter ก็จะมีคำสั่งพวกนี้เหมือนกัน แต่ก็มีข้อเสียตรงที่ Help ของ Diskpart จะไม่มีรายละเอียดของค่า Parameter (ตัวแปลเสริม) ให้คุณได้ศึกษากัน


A. ตารางคำสั่งของ Diskpart

คำสั่งของ Diskpart ที่คุณเห็นอยู่ในตารางนี้ เป็นแบบละเอียด 
Note: ถ้าคุณต้องการอ่านคำอธิบาย เป็นภาษาไทย (หรือภาษาอื่นที่ไม่ใช่อังกฤษ) ให้คุณคลิกเลือกที่ปุ่มเปลี่ยนภาษา ( Languge Button) ที่ด้านบน / ขวา ของเว็บเพจ
Note:
syntax หมายถึง วากยสัมพันธ์, การสร้างประโยค, กฏเกณฑ์ หรือวิธีการนำคำสั่งมาใช้ครับ. ภาษาคอมพิวเตอร์มันก็เป็นการจำลองรูปแบบคล้ายๆกับภาษามนุษย์ กล่าวคือ แต่ละภาษาก็จะมีไวยกรณ์ของมันเอง
Commands Syntax Descriptions
a active active
On basic disks, marks the partition with focus as active. This informs the basic input/output system (BIOS) or Extensible Firmware Interface (EFI) that the partition or volume is a valid system partition or system volume. Only partitions can be marked as "active."
*Important: DiskPart verifies that only the partition is capable of containing an operating system's startup files. DiskPart does not check the contents of the partition. If you mark a partition as "active" and it does not contain the operating system's startup files, your computer might not start.
add add disk= n [noerr]
Add a mirror to a simple volume.
Mirrors the simple volume with focus to the specified disk. This command is not valid on Windows Vista.
n
Specifies the disk to contain the mirror. You can mirror only simple volumes. The specified disk must have unallocated space at least as large as the size of the simple volume that you intend to mirror.
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 parameter, an error causes DiskPart to exit with an error code.
assign assign [{letter=d|mount=path}] [noerr]
Assigns a drive letter or mount point to the volumewith focus. If no drive letter or mount point is specified, then the next available drive letter is assigned. If the assigned drive letter or mount point is already in use, an error is generated.
By using the assign command, you can change the drive letter associated with a removable drive.
You cannot assign drive letters to system volumes, boot volumes, or volumes that contain the paging file. You cannot assign a drive letter to an OEM partition or any GPT partition other than a basic data partition.
letter= d
Specifies the drive letter that you intend to assign to the volume.
mount= path
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 thenoerr parameter, an error causes DiskPart to exit with an error code.
attributes attributes volume" [{set | clear}] [{hidden | readonly | nodefaultdriveletter | shadowcopy}] [noerr]
Manipulate volume or disk attributes.
volume
Displays the attributes of the selected volume.
set
Sets the specified attribute (hidden, read-only,nodefaultdriveletter, or shadowcopy volume) on the selected volume.
clear
Clears the specified attribute (hidden, read-only,nodefaultdriveletter, or shadowcopy volume) 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, DiskPart continues to process commands as if the error did not occur. Without the noerr parameter, an error causes DiskPart to exit with an error code.
attach attach Attaches a virtual disk file.
automount automount [enable] [disable] [scrub] [noerr]
Enable and disable automatic mounting of basic volumes.
When enabled (the default), Windows automatically mounts the file system for a new basic volume when it is added to the system, and then assigns a drive letter to the volume. In system area network configurations, disabling automount prevents Windows from automatically mounting or assigning drive letters to any new basic volumes added to the system.
enable
Enables Windows to automatically mount new basic volumes added to the system and to assign them drive letters.
disable
Prevents Windows from automatically mounting any new basic volumes that are added to the system.
scrub
Removes volume mount point directories and registry settings for volumes that are no longer in the system. This prevents volumes that were previously in the system from being automatically mounted and given their former volume mount point(s) when they are added back to the system.
noerr
For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without thenoerr parameter, an error causes DiskPart to exit with an error code.

b break break disk= n [nokeep] [noerr]
Break a mirror set.
Applies to dynamic disks only. Breaks the mirrored volume with focus into two simple volumes. One simple volume retains the drive letter and any mount points of the mirrored volume, while the other simple volume receives the focus so 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.
n
Specifies the disk that contains the mirrored volume.
nokeep
Specifies that only one 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 thenoerr parameter, an error causes DiskPart to exit with an error code.
c_down_gray






























c_down_gray[1]































c_down_gray[2]






























c_down_gray[3]







































c

clean clean [all]
Clear the configuration information, or all information, off the disk.
Removes any and all partition or volume formatting from the disk with focus. On master boot record (MBR) disks, only the MBR partitioning information and hidden sector information are overwritten. On GUID partition table (GPT) disks, the GPT partitioning information, including the Protective MBR, is overwritten; there is no hidden sector information.
all
Specifies that each and every sector on the disk is zeroed, which completely deletes all data contained on the disk.
compact compact Attempts to reduce the physical size of the file.
CONVERT Convert between different disk formats.
convert basic convert basic [noerr]
Converts an empty dynamic disk into a basic disk.
Important 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.
noerr For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without thenoerr parameter, an error causes DiskPart to exit with an error code.
convert dynamic convert dynamic [noerr]
Converts a basic disk into a dynamic disk. Any existing partitions on the disk become simple volumes.
noerr For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without thenoerr parameter, an error causes DiskPart to exit with an error code.
convert gpt convert gpt [noerr]
On Itanium-based computers, converts an empty basic disk with the master boot record (MBR) partition style into a basic disk with the GUID partition table (GPT) partition style.
Important 
The disk must be empty to convert it to a GPT disk. Back up your data and then delete all partitions or volumes before converting the disk.
noerr For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without thenoerr parameter, an error causes DiskPart to exit with an error code.
convert mbr convert mbr [noerr]
On Itanium-based computers, converts an empty basic disk with the GUID Partition Table (GPT) partition style to a basic disk with the master boot record (MBR) partition style.
Important
The disk must be empty to convert it to an MBR disk. Back up your data and then delete all partitions or volumes before converting the disk.
noerr For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without thenoerr parameter, an error causes DiskPart to exit with an error code.
CREATE Create a volume, partition or virtual disk.
- create partition efi create partition efi [size=n] [offset=n] [noerr]
On Itanium-based computers, creates an Extensible Firmware Interface (EFI) system partition on a GUID Partition Table (GPT) disk. After the partition has been created, the focus is given to the new partition.
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 placed in the first disk extent 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 thenoerr parameter, an error causes DiskPart to exit with an error code.
create partition extended create partition extended [size=n] [offset=n] [noerr]
Creates an extended partition on the current drive. After the partition has been created, the focus automatically shifts to the new partition. Only one extended partition can be created per disk. This command fails if you attempt to create an extended partition within another extended partition. You must create an extended partition before you can create logical drives.
size= n Specifies the size of the extended partition in megabytes (MB). If no size is given, then the partition continues until there is no more free space in the region. The size is cylinder snapped; that is, the size is rounded to the closest cylinder boundary. For example, if you specify a size of 500 MB, the partition size rounds up to 504 MB.
offset= n Applies to master boot record (MBR) disks only. Specifies the byte offset at which to create the extended partition. If no offset is given, the partition starts at the beginning of the first free space on the disk. The offset is cylinder snapped; that is, the offset is rounded to the closest cylinder boundary. For example, if you specify an offset that is 27 MB and the cylinder size is 8 MB, the offset is rounded to the 24-MB 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 thenoerr parameter, an error causes DiskPart to exit with an error code.
create partition logical create partition logical [size=n] [offset=n] [noerr]
Creates a logical drive in the extended partition. After the partition has been created, the focus automatically shifts to the new logical drive.
size= n The size of the logical drive in megabytes (MB). If no size is given, then the partition continues until there is no more free space in the current region.
offset= n Applies to master boot record (MBR) disks only. Specifies the byte offset at which to create the logical drive. The offset is cylinder snapped; that is, 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 drive, 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 thenoerr parameter, an error causes DiskPart to exit with an error code.
create partition msr create partition msr [size=n] [offset=n] [noerr]
On Itanium-based computers, creates a Microsoft reserved (MSR) partition on a GUID Partition Table (GPT) disk.
Caution
Be very careful when using the create partition msrcommand. GPT disks require a specific partition layout, and so creating Microsoft Reserved Partitions can cause the disk to become unreadable. On GPT disks that are used to start Windows XP 64-Bit Edition or the 64-bit versions of the Windows Server 2003 family, the EFI system partition is the first partition on the disk, followed by the Microsoft Reserved Partition. GPT disks used only for data storage do not have an EFI system partition; the Microsoft Reserved Partition is the first partition.
Windows XP and the Windows Server 2003 family do not mount Microsoft Reserved Partitions. You cannot store data on them and you cannot delete them.
size= n
Specifies the size of the partition in megabytes (MB). The partition is at least as long in bytes as the number specified by size=n. 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. The partition starts at the byte offset specified by offset=n. It is sector-snapped; that is, the offset rounds up to completely fill whatever sector 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.
noerr For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without thenoerr parameter, an error causes DiskPart to exit with an error code.
create partition primary create partition primary [size=n] [offset=n] [ID={byte|GUID}] [align=n][noerr]
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 partition in megabytes (MB). If no size is given, the partition continues until there is no more unallocated space in the current region. The size is cylinder snapped; that is, the size rounds to the closest cylinder boundary. For example, if you specify a size of 500 MB, the partition size rounds up to 504 MB.
offset= n
Specifies the byte offset at which to create the partition. If no offset is given, the partition starts at the beginning of the first free space on the disk. For master boot record (MBR) disks, the offset is cylinder snapped; that is, the offset rounds to the closest cylinder boundary. For example, if you specify an offset that is 27 MB and the cylinder size is 8 MB, the offset rounds to the 24-MB boundary.
ID={byte|GUID}
Intended for OEM use only.
Caution Creating partitions with this parameter might cause your computer to crash or be unable to start. Unless you are an OEM or an IT professional experienced with GPT disks, do not create partitions on GPT disks by using the ID=byte |GUID parameter. Instead, always use the create partition efi command to create EFI system partitions, the create partition msr command to create Microsoft Reserved Partitions, and thecreate partition primary command (without theID=byte | GUID parameter) to create primary partitions on GPT disks.
align= n
Typically used with hardware RAID Logical Unit Number (LUN) arrays to improve performance when the logical units (LUs) are not cylinder aligned. Aligns a primary partition that is not cylinder aligned at the beginning of a disk and rounds the offset to the closest alignment boundary, where n is the number of kilobytes (KB) from the beginning of the disk to the closest alignment boundary. The align= n command fails if the primary partition is not at the beginning of the disk. If used with offset= n, the offset is within the first usable cylinder on 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 thenoerr parameter, an error causes DiskPart to exit with an error code.
Comments
To partition a GPT disk with an OEM partition generate an OEM-GUID:
Use this command to create an EFI partition:
create partition efi size= n
Use this command to create a primary partition:
create partition primary size= n ID={byte|GUID}
Use this command to create an MSR partition:
create partition MSR size= n

Important 
You must create the OEM partition between the EFI and MSR partitions.
Never create the LDM metadata or LDM data partitions explicitly as partitions. Instead, convert the disk to dynamic.
For master boot record (MBR) disks, you can specify a partition type byte, in hexadecimal form, for the partition. If you do not specify a partition type byte on an MBR disk, the create partition primarycommand creates a partition of type 0x6. Any partition type byte can be specified with theID=byte | GUID parameter. DiskPart does not verify the validity of the partition type nor does it verify the ID parameter.
  • For GPT disks, you can specify a partition type GUID for the partition that you create.
  • 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
If you do not specify a partition type GUID, thecreate partition primary command creates a basic data partition. Any partition type can be specified with the ID=byte | GUID parameter. DiskPart does not verify the validity of the partition GUID nor does it verify the ID parameter.
create volume raid create volume raid [size=n] [disk=n,n,n[,n,…]] [noerr]
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. This command is not valid on Windows Vista.
size= n
Specifies the amount of 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 with 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 of the disk space is required for parity.
disk= n , n , n[,n,…]
Specifies the dynamic disks on which to create the volume. You need at least three dynamic disks in order to create a RAID-5 volume. An amount of space equal to size=n is allocated on each 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 thenoerr parameter, an error causes DiskPart to exit with an error code.
create volume simple create volume simple [size=n] [disk=n] [noerr]
Creates a simple volume. After you create the volume, the focus automatically shifts to the new volume. Dynamic disks are not supported on Windows Vista Starter, Windows Vista Home Basic, Windows Vista Home N, and Windows Vista Business operating systems.
size= n
Specifies the size of the volume in megabytes (MB). If no size is given, the new volume takes up 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.
noerr
For scripting only. When an error is encountered, specifies that DiskPart continues to process commands as if the error did not occur. Without thenoerr parameter, an error causes DiskPart to exit with an error code.
create volume stripe create volume stripe [size=n] [disk=n,n[,n,…]] [noerr]
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. Dynamic disks are not supported on Windows Vista Starter, Windows Vista Home Basic, Windows Vista Home N, and Windows Vista Business operating systems.
size= n
Specifies the amount of disk space, in megabytes (MB), that the volume occupies on each disk. If no size is given, the new volume takes up 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 volume. You need at least two dynamic disks to create a striped volume. An amount of space equal to size=n is allocated on each 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 thenoerr parameter, an error causes DiskPart to exit with an error code.


d
DELETE Delete an object.
delete disk delete disk [noerr] [override]
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 thenoerr parameter, 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 delete partition [noerr] [override]
On a basic disk, deletes the partition with focus. You cannot delete the system partition, boot partition, or any partition that contains the active paging file or crash dump (memory dump).
Caution 
Deleting a partition on a dynamic disk can delete all dynamic volumes on the disk, thus 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, but you must not create them. For example, it is possible to 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 situation where the clean command cannot be used.
noerr For scripting only. When an error occurs, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerrparameter, an error causes DiskPart to exit with an error code.
override Enables DiskPart to delete any partition regardless of type. Normally, DiskPart enables you to delete only known data partitions.
delete volume delete volume [noerr]
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 occurs, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerrparameter, an error causes DiskPart to exit with an error code.
DETAIL Provide details about an object.
detail disk detail disk Displays the properties of the selected disk and the volumes on that disk.
detail partition detail partition Displays the properties of the selected partition.
detail volume detail volume Displays the disks on which the current volume resides.
detach detach Detaches a virtual disk file.
e exit exit Exit DiskPart.
extend
extend [size=n] [disk=n] [noerr]
Extends the volume with 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 higher sector offset number than) the partition with focus. A dynamic, simple, or spanned volume can be extended to any empty space 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 with no change to the partition.
You cannot extend the current system or boot partitions.
size= n
Specifies the amount of space, in megabytes (MB), to add to the current partition. If you do not specify a size, the disk is extended to take up all of 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 occurs, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerrparameter, an error causes DiskPart to exit with an error code.
expand Expands the maximum size available on a virtual disk.
f
filesystems
filesystems
Displays current and supported file systems on the volume. A volume must be selected for this operation to succeed.
format format [{[FS=<FS>] [REVISION=<X.XX>] | RECOMMENDED}] [LABEL=<"label">] [UNIT=<N>] [QUICK] [COMPRESS] [OVERRIDE] [NOWAIT] [NOERR]
Formats the volume or partition. A volume must be selected for this operation to succeed.
FS=<FS> Specifies the type of file system. If no file system is given, the default file system displayed by the FILESYSTEMS command is used.
REVISION = <X.XX> Specifies the file system revision (if applicable).
RECOMMENDED If specified, use the recommended file system and revision instead of the default if a recommendation exists. The recommended file system (if one exists) is displayed by 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. The default allocation unit size for a particular file system is displayed by the FILESYSTEMS command.
NTFS compression is not supported for allocation unit sizes above 4096.
QUICK Performs a quick format.
COMPRESS NTFS only: Files created on the new volume will be compressed by default.
OVERRIDE Forces the volume to dismount first if necessary. All opened handles to the volume would no longer be valid.
NOWAIT Forces the command to return immediately while the format process is still in progress. If NOWAIT is not specified, DiskPart will display format progress in percentage.
NOERR For scripting only. When an error is encountered, DiskPart continues to process commands as if the error did not occur. Without the NOERR parameter, an error causes DiskPart to exit with an error code.
Examples: FORMAT FS=NTFS LABEL="New Volume" QUICK COMPRESS FORMAT RECOMMENDED OVERRIDE
g
gpt attributes
gpt attributes= n

On basic GPT disks, assigns the GPT attribute(s) to the partition with focus. GPT partition attributes give additional information about the use of the partition. Some attributes are specific to the partition type GUID.
Important  Changing the GPT attributes might cause your basic data volumes to be unmountable or fail to be assigned drive letters. Unless you are an OEM or an IT professional experienced with GPT disks, do not change GPT attributes.
n The hexadecimal that pertains to the attribute that you intend to apply to the partition with focus. The GPT attribute field is a 64-bit field that contains two subfields. The higher field is interpreted only in the context of the partition ID, while the lower field is common to all partition IDs.
All partitions have the following attribute:
  • 0x000000000000001 marks the partition as required. This indicates to all disk management utilities that the partition must not be deleted. The EFI system partition contains only those binaries necessary to start the operating system. This makes it easy for OEM- or operating system-specific binaries to be placed in other partitions.
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 ensures that, when a disk is moved to a new computer, a new drive letter will not be automatically generated. Instead, the user can manually assign drive letters.
  • Note
  • Other attributes can be added at any time.
H help help
Displays a list of the available commands.
i
import
import [noerr]
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 focus.
noerr
For scripting only. When an error occurs, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerrparameter, an error causes DiskPart to exit with an error code.
inactive
inactive
Mark the selected partition as inactive.
On basic master boot record (MBR) disks, marks the system partition or boot partition with focus as inactive. The computer starts from the next option specified in the BIOS such as the CD-ROM drive or a Pre-Boot eXecution Environment (PXE)-based boot environment (such as Remote Installation Services (RIS)) when you restart the computer.
Caution
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 with a thorough understanding of the Windows Server 2003 family.
If you are unable to start your computer after marking the system or boot partition as inactive, insert the Setup CD in the CD-ROM drive, restart the computer, and then repair the partition by using the Fixmbr and Fixboot commands in the Recovery Console.
l
list disk list 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 focus.
list partition list partition Displays the partitions listed in the partition table of the current disk. On dynamic disks, these partitions may not correspond to the dynamic volumes on the disk. This discrepancy occurs because dynamic disks contain entries in the partition table for the system volume or boot volume (if present on the disk). Dynamic disks also contain a partition that occupies the remainder of the disk and reserves space for use by dynamic volumes.
list volume
list volume
Displays a list of basic and dynamic volumes on all disks.
M merge merge Merges a child disk with its parents.
o
online
online [noerr]
Brings an offline disk or volume with focus online. Resynchronizes the mirrored or RAID-5 volume with focus.
noerr For scripting only. When an error occurs, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerrparameter, an error causes DiskPart to exit with an error code.
offline offline Offline an object that is currently marked as online.
r reconvers reconvers Refreshes the state of all disks in the selected pack. Attempts recovery on disks in the invalid pack, and resynchronizes mirrored volumes and RAID5 volumes that have stale plex or parity data.
rem rem
Provides a way to add comments to a script.
For example:
rem These commands set up 3 drives. create partition primary size=2048 assign d: create partition extend create partition logical size=2048 assign e: create partition logical assign f:
remove
remove [{letter=d|mount=path|[all]}] [dismount][noerr]
Removes a drive letter or mount point from the volume with 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, then 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 GPT partition with an unrecognized GUID, or any of the special, non-data, GPT partitions such as the EFI system partition.
letter= d
Specifies the drive letter to remove.
mount= path Specifies the mount point path to remove.
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.Dismount will fail if used on a volume that has any remaining drive letters or mount points. For scripting, using removeall dismount is recommended.
noerr For scripting only. When an error occurs, specifies that DiskPart continues to process commands as if the error did not occur. Without the noerrparameter, an error causes DiskPart to exit with an error code.
repair disk
repair disk= n [noerr]
Repairs the RAID-5 volume with focus by replacing the failed RAID-5 member with the specified dynamic disk. The specified dynamic disk must have free space greater than or equal to the total size of the failed RAID-5 member.
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.
noerr For scripting only. When an error occurs, DiskPart continues to process commands as if the error did not occur. Without the noerr parameter, an error causes DiskPart to exit with an error code.
rescan
rescan
Rescan the computer looking for disks and volumes.
Locates new disks that might have been added to the computer.
retain
retain
Place a retained partition under a simple volume.
Prepares an existing dynamic simple volume to use as a boot or system volume.
On an x86-based computer, creates a partition entry in the master boot record (MBR) on the dynamic simple volume with focus. To create an MBR partition, the dynamic simple volume must start at a cylinder aligned offset and be an integral number of cylinders in size.
On an Itanium-based computer, creates a partition entry in the GUID partition table (GPT) on the dynamic simple volume with focus.
Note
The retain command is intended for use only during unattended Setup or by OEMs.
s




























s[1]
san Display or set the SAN policy for the currently booted OS.
select disk select disk=[n]
Selects the specified disk and shifts the focus to it.
n Specifies the disk number of the disk to receive focus. If you do not specify a disk number, theselect command lists the disk that currently has the focus. You can view the numbers for all disks on the computer by using the list disk command.
select partition
select partition=[{n|d}]
Selects the specified partition and gives it focus. If you do not specify a partition, the select command lists the current partition with focus. You can view the numbers of all partitions on the current disk by using the list partition command.
n Specifies the number of the partition to receive the focus.
d Specifies the drive letter or mount point path of the partition to receive the focus.
select volume select volume=[{n|d}]
Selects the specified volume and shifts the focus to it. If you do not specify a volume, the selectcommand lists the current volume with focus. You can specify the volume by number, drive letter, or mount point path. On a basic disk, selecting a volume also gives the corresponding partition focus. You can view the numbers of all volumes on the computer by using the list volume command.
n Specifies the number of the volume to receive the focus.
d Specifies the drive letter or mount point path of the volume to receive the focus.
setid
setid={<BYTE> | <GUID>} [OVERRIDE] [NOERR]
Change the partition type. Intended for Original Equipment Manufacturer (OEM) use only. A partition must be selected for this operation to succeed.
ID={<BYTE> | <GUID>} Specifies the new partition type. For master boot record (MBR) disks, you can specify a partition type byte, in hexadecimal form, for the partition. Any partition type byte can be specified with this parameter except for type 42 (LDM partition).
For GUID partition table (GPT) disks you can specify a partition type GUID for the partition.
OVERRIDE Enables DiskPart to force the volume to dismount first if necessary. All opened handles to the volume will become invalid.
NOERR For scripting only. When an error is encountered, DiskPart continues to process commands as if the error did not occur. Without the NOERR parameter, an error causes DiskPart to exit with an error code.
Caution: Changing partition type fields 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 GPT disks, do not change partition type fields on GPT disks using this parameter. Instead, always use the CREATE PARTITION EFI command to create EFI 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.
This command does not work on dynamic disks nor on Microsoft Reserved partitions.
Example:
SET ID=07 OVERRIDE
SET ID=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
shrink
shrink [DESIRED=<N>] [MINIMUM=<N>] [NOWAIT] [NOERR]
shrink QUERYMAX [NOERR]
Reduce the size of the selected volume.
Reduces the size of the volume with focus by the specified amount. Makes free disk space available from unused space at the end of the volume. A volume must be selected for this operation to succeed.
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 maximum amount of free space available on the volume.
MINIMUM=<N> Specifies the minimum amount of space in MB to reduce the size of the volume by.
QUERYMAX Returns the maximum number of bytes that the volume can be reduced by (the free space available on the volume). This value may change if applications are currently accessing the volume.
NOWAIT Forces the command to return immediately while the shrink process is still in progress.
NOERR For scripting only. When an error is encountered, DiskPart continues to process commands as if the error did not occur. Without the NOERR parameter, an error causes DiskPart to exit with an error code.
If a MINIMUM amount is not specified, the volume will be reduced by either the DESIRED amount (if specified), or by the maximum amount of free space available on the volume. If a MINIMUM amount is specified but not enough free space is available, the command will fail.
This command works on basic volumes, and on simple or spanned dynamic volumes. 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.
Examples:
SHRINK DESIRED=500 MINIMUM=250
SHRINK QUERYMAX
U
uniqueid
Displays or sets the GUID partition table (GPT) identifier or
master boot record (MBR) signature of a disk.


Funny Animited

 

 

ตัวอย่างการใช้ diskpart command

 







ไม่มีความคิดเห็น :