命令行大全

diskpart

秃噜豆儿 发表于 2020-06-22 15:54浏览次数:

diskPart是一个命令行磁盘分区实用程序,可用于Microsoft操作系统。您可以使用它来查看,创建,删除和修改计算机的磁盘分区。

查看英文版

目录:

1 diskpart 运行系统环境

2 如何使用diskPart

3 diskPart 命令

4 diskPart 示例

diskpart 运行系统环境

Windows xp

Windows vista

Windows 2000

Windows 7

Windows 8

Windows 10

如何使用diskPart

您的Windows用户帐户必须是Administrators组的成员才能使用diskPart。

diskPart可执行文件diskpart.exe具有两个选项:

diskpart [/s script] [/?]
/s script 执行名为script的文本文件中包含的DiskPart命令,一次执行一行。
/? 显示此帮助消息。

如果未指定任何选项,则运行diskpart会启动diskPart交互式命令提示符,您可以在其中运行diskPart命令。有关如何启动diskPart和运行命令的更多信息,请参见示例。

Your Windows user account must be a member of the Administrators group to use DiskPart.

The DiskPart executable file, diskpart.exe, has two options:

diskpart [/s script] [/?]
/s script Execute the DiskPart commands contained in the text file named script, one line at a time.
/? Display this help message.

If no options are specified, running diskpart starts the DiskPart interactive command prompt, where you can run DiskPart commands. For more information about how to start DiskPart and run commands, see examples.

查看英文版

查看中文版

diskPart 命令

默认情况下,如果diskPart遇到错误,它将以非零退出状态终止。 一些diskPart命令接受noerr选项。如果指定了noerr,diskPart将忽略遇到的任何错误,并尝试继续进行后续操作。此选项有潜在的危险,应谨慎使用。

命令 子命令,语法和描述
active
active

将所选分区标记为“活动”,向您的计算机的BIOS或UEFI指示该分区包含可引导系统。例如,安装Microsoft Windows的分区是活动分区。

请注意,只有基本磁盘(与动态磁盘(例如RAID阵列)相对)上的分区可以标记为活动。

注意,diskPart并不实际检查分区的内容以验证其是否包含可引导系统文件。

add
add disk=n [align=n] [wait] [noerr]

在分区n上创建所选磁盘对象的镜像,该镜像必须是简单卷。分区n必须具有等于或大于所选卷的大小的未分配空间,否则无法创建镜像。

如果成功,则所选的简单卷将成为镜像卷,并且该镜像存储在分区n中。注意,此命令在Windows Vista中无效。

assign
assign [letter=d | mount=path] [noerr]

将驱动器号或安装的文件夹路径名分配给选定的卷。如果未指定驱动器号d或已安装的文件夹路径,则分配下一个可用的盘符。

如果驱动器号或装入的文件夹已在使用中,则操作将失败并报告错误。分配给可移动驱动器的驱动器号可以更改。

您不能为启动卷或包含Windows 页面文件的卷分配驱动器号。您不能将驱动器号分配给OEM分区(Windows PE(预安装环境)除外。

您不能将驱动器号分配给任何GPT(GUID分区表)分区,而不是基本数据分区。您不能将驱动器号分配给ESP分区。您不能将驱动器号分配给恢复分区。

attributes
attributes disk [set | clear] [readonly] [noerr]

设置,清除或显示所选磁盘的属性(标志)。该只读标志指示盘写保护(只读)。如果组被指定,标志设置。如果指定了clear,则该标志未设置。

如果未提供任何选项,则显示当前磁盘标志。可能会显示“只读”以外的磁盘标志,但无法设置或清除。

attributes volume [{set | clear}] [{hidden | readonly | nodefaultdriveletter | shadowcopy}] [noerr]

设置,清除或显示所选卷的属性(标志)。该只读标志表明该卷是写保护。该隐藏的标志表明该卷不应该被显示在卷列表,例如在文件浏览器。

所述nodefaultdriveletter标志表明该卷不应该自动安装和分配驱动器号。该影拷贝标志表明该卷是一个卷影副本卷,由Windows VSS服务使用。

如果指定了set,则设置这些标志。如果指定了clear,则未设置这些标志。如果未提供任何选项,则显示当前音量标志。

在基本MBR上磁盘,隐藏,只读和nodefaultdriveletter属性始终应用于磁盘上的所有卷。在基本GPT(GUID分区表)磁盘,

动态MBR磁盘和动态GPT磁盘上,这些属性仅适用于选定的卷。

attach
attach vdisk [ readonly ] [sd=sddl-string] [usefilesd] [noerr]

附加(挂载)VHD(虚拟硬盘)或VHDX(Hyper-V虚拟硬盘)文件。随附的VHD显示为本地硬盘驱动器。

如果VHD已具有带有有效文件系统的磁盘分区,则虚拟磁盘已分配驱动器号。如果指定了readonly,则以只读模式挂载磁盘。

如果指定了sd,并且sddl-string是有效的SDDL安全描述符字符串,则该描述符将应用于整个磁盘。如果指定了usefilesd,

则VHD文件本身的安全描述符将应用于整个磁盘。

有关安全描述符的更多信息,请参见下面的create vdisk。

automount
automount [enable | disable | scrub] [noerr]

配置自动安装功能,该功能会自动安装驱动器号并将其分配给新连接到系统的磁盘。如果指定了enable,将自动安装新磁盘,

并为其分配驱动器号和卷GUID路径名。如果指定了禁用,则禁用此功能。如果指定了scrub,

则将为不再连接到系统的卷删除所有现有的文件夹路径名,驱动器号,装入的文件夹目录和注册表设置。

在Windows Vista之前,自动安装功能仅在基本磁盘卷上可用。在Vista和更高版本中,动态磁盘卷上也提供了AutoMount。

break
break disk=n [nokeep] [noerr]

将选定的镜像卷分成两个简单卷。仅适用于动态磁盘。其中一个简单卷将保留镜像卷的已分配驱动器号,GUID路径名和已安装的文件夹路径(如果有)。

选择了另一个卷,因此您可以为其分配驱动器号。完成后,将自动分配一个GUID路径名。默认情况下,两个简单卷都保留原始镜像卷的数据。

如果指定了nokeep选项,则只有一个简单卷保留数据,而另一个简单卷则清除数据,并且不被选择。

clean
clean [all]

从所选磁盘中删除所有分区和卷格式。如果全部指定,则磁盘上的每个字节都会被覆盖为零,从而破坏整个磁盘上的所有现有信息。

在MBR磁盘上,仅MBR分区信息和隐藏扇区信息会被覆盖。在GPT磁盘上,除了GPT信息外,保护性MBR也被覆盖。

如果全部省略,则仅磁盘的第一个和最后一个1 MB被覆盖为零。成功清理之后,磁盘的状态在DiskPart中列为“未初始化”。

compact
compact vdisk
尝试减小所选的可扩展VHD文件的大小。VHD必须是可扩展的,操作才能成功。即使将虚拟磁盘安装为只读磁盘,也可以压缩VHD文件。
convert
convert basic [noerr]
将选定的空动态磁盘转换为基本磁盘。必须从磁盘上删除所选磁盘上的所有数据,并删除其所有分区和卷,否则操作将失败。
convert dynamic [noerr]
将选定的基本磁盘转换为动态磁盘。磁盘上的任何卷都将成为简单卷。
convert gpt [noerr]
将所选的空的基本MBR磁盘转换为基本GPT磁盘。必须从磁盘上删除所选磁盘上的所有数据,并删除其所有分区和卷,否则操作将失败。
convert mbr [noerr]
将选定的空基本GPT磁盘转换为基本MBR磁盘。必须从磁盘上删除所选磁盘上的所有数据,并删除其所有分区和卷,否则操作将失败。
create
create partition efi [size=n] [offset=n] [noerr]

在聚焦的基本GPT磁盘上创建EFI(可扩展固件接口)系统分区。如果指定了偏移量,则分区从与磁盘开头偏移n KB 的磁盘区域开始,

否则从磁盘上足够大小的第一个可用位置开始。所述分区的大小是Ñ兆字节,

如果尺寸指定,否则该分区使用在盘的该区域中的所有可用空间。如果操作成功,则对新分区进行聚焦。

create partition extended [size=n] [offset=n] [align=n] [noerr]

在聚焦的基本MBR磁盘上创建扩展分区。磁盘上只能存在一个扩展分区(以后可以将其划分为逻辑分区)。如果指定了偏移量,则分区从n KB 开始,

否则在足够大小的第一个可用位置开始。如果指定了大小,则大小为n兆字节,否则它将占用磁盘上所有从偏移量开始的可用空间。如果指定align,

则分区的偏移量将舍入为n KB 的倍数,这在将RAID配置与LUN(逻辑单元号)

一起使用时可能会提高性能。

create partition logical [size=n] [offset=n] [align=n] [noerr]

在聚焦的基本MBR磁盘的扩展分区中创建逻辑分区。如果指定了偏移量,则该分区从扩展分区的开始处开始n KB ,否则从扩展分区的第一个可用空间开始。

如果指定了大小,则大小为n兆字节,否则它将使用扩展分区中从偏移量开始的所有可用空间。

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

在聚焦的GPT磁盘上创建一个MSR(Microsoft保留)分区。如果指定了偏移量,则分区将从n KB 开始,否则从磁盘上的第一个可用位置开始。

尺寸为ñ兆字节,如果大小指定,否则将使用所有可用空间。请谨慎使用该命令,因为GPT磁盘对分区布局有严格的要求,

并且违反这些规则的布局可能会导致磁盘无法启动。在用于引导Windows的GPT磁盘上,

EFI系统分区必须是磁盘上的第一个分区,然后是MSR分区。

在不具有EFI系统分区(仅用于数据存储,磁盘上没有可引导的OS)的GPT磁盘上,MSR分区必须是磁盘上的第一个分区。

create partition primary [size=n] [offset=n] [id={byte|guid}] [align=n] [noerr]

在聚焦的基本磁盘上创建一个主分区。如果指定了偏移量,则分区将从n KB 开始,否则从磁盘上的第一个可用空间开始。

如果指定了大小,则大小为n兆字节,否则将使用从偏移量开始的所有可用空间。

如果指定align,则偏移量将舍入为n KB 的倍数,这可以提高使用LUN的RAID配置的性能。对于MBR磁盘,默认分区类型为“无文件系统”,

对于GPT磁盘,默认分区类型为“基本数据分区”。成功创建分区后,DiskPart会自动将其聚焦。驱动器字母必须手动地与所分配的分配 命令。

可以使用id选项手动指定分区类型。请注意,此选项仅适用于OEM。

对于MBR磁盘,将分区类型字节指定为十六进制值,并删除前导0x(例如,对于“无文件系统”为06,对于“恢复分区”为27)。

对于GPT磁盘,分区类型由GUID值指定(例如,对于“基本数据分区”,为ebd0a0a2-b9e5-4433-87c0-68b6b72699c7,

对于“恢复分区”,则为de94bba4-06d1-4d40-a16a-bfd50179d6ac)。

要查看已识别分区类型的列表,请运行help create partition primary。 使用id选项时请多加注意。您指定的值将被设置,即使它无法识别或不正确。

错误使用id选项可能导致计算机无法启动。

create volume raid [size=n] disk=n,n,n[,n[,...]] [align=n [noerr]

从三个或更多动态磁盘创建一个raid-5卷。必须使用disk参数指定要使用的磁盘,并用逗号分隔驱动器号,例如disk = 3,4,7或disk = 5,6,7,8。

如果指定align,则所有卷扩展区都将舍入为n KB 的倍数,这可以通过硬件RAID LUN配置提高性能。操作成功后,新卷将自动聚焦。

请注意,Windows Vista不支持RAID-5卷。

create volume simple [size=n] [disk=n] [align=n] [noerr]

在聚焦的动态磁盘或使用disk参数指定的磁盘上创建一个简单卷。它的大小是ñ兆字节,如果大小指定,否则它使用磁盘上的所有可用空间。

如果指定align,则卷边界将舍入为n KB 的倍数,这可以提高硬件RAID性能。成功创建卷后,新卷将自动聚焦。

create volume stripe [size=n] [disk=n,n,n[,n[,...]]] [align=n] [noerr]

使用两个或多个动态磁盘创建带区卷。磁盘号必须由disk参数指定为逗号分隔的列表,例如disk = 3,4或disk = 4,5,7。

卷的大小是Ñ兆字节,如果尺寸指定,否则它使用最小的磁盘上的最大可用空间和空间上的其他磁盘等量。

如果指定align,则卷边界将舍入为n KB的倍数。成功创建卷后,它将自动聚焦。

create volume mirror [size=n] disk=n,n,n[,n[,...]] [align=n] [noerr]

使用两个动态磁盘创建一个镜像卷。磁盘必须由磁盘编号指定,例如disk = 2,3或disk = 3,5。

所述分区的大小是Ñ兆字节,如果尺寸指定,否则它使用较小的磁盘上的剩余空闲空间,以及空间上的其它等量。

如果指定align,则卷边界将舍入为n KB 的倍数,这可以提高使用LUN的硬件RAID配置的性能。成功创建卷后,新卷将自动聚焦。

create vdisk file="filename" maximum=n [type={fixed|expendable}] [sd=sddl-string] [parent="parentfile"] [source="sourcefile"] [noerr]

创建一个虚拟磁盘文件。支持VHD和VHDX文件格式,并由文件扩展名.vhd或.vhdx指定。

目标文件名由必需的file参数指定,其中destfile是目标虚拟磁盘文件的完整路径和文件名,例如“ C:\ my-vdisk.vhd”。

的最大参数设置由虚拟磁盘露出的最大磁盘空间Ñ兆字节。所述类型参数指定如果盘大小是固定的(大小永远不能改变,缺省值)

或可膨胀的(在磁盘文件的自由空间可以被后来扩展或压缩)。 如果来源指定后,将使用现有虚拟磁盘sourcefile中的数据填充新虚拟磁盘。

如果指定了parent,则将虚拟磁盘创建为Hyper-V差异磁盘,仅包含从parentfile更改的块数据(现有的相同大小的虚拟磁盘)。

虚拟磁盘的安全描述符设置为与目标文件的父目录匹配,如果指定了sd,则设置为SDDL格式字符串sddl-string。

有关有效SDDL字符串的详细信息,请运行help create vdisk。

delete
delete disk [override] [noerr]

从磁盘列表中删除缺少焦点的动态磁盘。如果指定了override,DiskPart将删除磁盘上的所有简单卷。

如果磁盘包含镜像卷的一半,则将删除磁盘上一半的镜像。一个覆盖如果磁盘是一个RAID-5卷的成员失败。

delete partition [override] [noerr]

删除聚焦的基本磁盘分区。如果它是系统分区,引导分区,或者包含活动的页面文件或故障转储文件,则无法删除它。

无法删除动态磁盘上的分区。

delete volume [noerr]
删除聚焦的音量。如果它是系统卷,引导卷或包含活动的页面文件或故障转储文件,则无法删除它。
detail
detail disk
显示聚焦磁盘的属性,并列出其卷。
detail partition
显示焦点分区的属性。
detail volume
显示聚焦的卷的属性,并列出该卷所在的磁盘。
detail vdisk
显示聚焦虚拟磁盘的属性。
detach
detach vdisk [noerr]
分离指定的虚拟磁盘。
exit
exit
退出diskPart。
extend extend [size=n] [disk=n] [noerr]

将聚焦的卷或分区以及可选的文件系统扩展到磁盘上的未分配空间。如果指定了大小,则卷将扩展n兆字节,否则将使用所有可用空间。

如果指定了disk,并且聚焦的卷或分区是动态磁盘,

则扩展名出现在磁盘号n上;否则,它会出现在原始磁盘上。在基本磁盘上,扩展必须始终在同一磁盘上,紧接在原始磁盘之后的空间中进行。

在具有简单卷或跨卷的动态磁盘上,可以将卷扩展到任何动态磁盘上的任何可用空间。

镜像卷,RAID-5卷和带区卷无法扩展。如果分区以前是使用NTFS格式化的,请展开 失败,并且不做任何更改。

extend filesystem [noerr]
扩展扩展卷或分区的文件系统。在原始的expand命令之后运行此命令,以同时扩展文件系统。
expand
expand vdisk maximum=n

扩展聚焦虚拟磁盘上可用的最大大小。所需的最大参数将新的总大小设置为n兆字节。

例如,maximum = 30000会将虚拟磁盘的新最大大小设置为30 GB。

filesystems
filesystems
显示有关所选卷的文件系统的信息,以及可以对其进行格式化的受支持文件系统的列表。
format
format [fs=fstype] [revision=X.XX] | [recommended] [label="label"] [unit=n] [quick] [compress] [override] [duplicate] [nowait] [noerr]

格式化聚焦的音量。如果指定了fs,则使用文件系统fstype;否则,使用filesystems命令列出的默认文件系统。

如果需要文件系统的特定修订版,则可以使用version指定。如果标签被指定,卷标设置为标签。

如果指定了单位,则默认分配单位大小将被覆盖并设置为n个字节。如果快速指定,一个快速格式化执行。如果指定compress并且fs = NTFS,

则NTFS文件系统将默认情况下压缩文件。如果指定了override,DiskPart将尝试在格式化之前强制卸载该卷。

如果指定重复并且fs = UDF(通用磁盘格式)修订版2.5或更高版本,则文件系统元数据将复制到磁盘上的第二组扇区(元数据冗余)。

如果指定了nowait,该命令将立即返回到提示,并在后台执行格式化。

gpt
gpt attributes=n
将指定的GPT属性分配给基本GPT磁盘上的焦点分区。此命令仅适用于OEM或IT专业人员。有关n的有效十六进制值的详细信息,请运行help gpt。
help
help [command] [subcommand ...]
显示带有语法和说明的命令和子命令的列表。例如,help,help help,help create或帮助创建分区efi。
import
import [noerr]

将与聚焦外部磁盘相同的磁盘组中的所有磁盘导入本地计算机的联机磁盘组。

“外部磁盘”是本地安装的任何先前在另一台计算机或Windows的其他版本上使用的动态磁盘。导入后,动态磁盘卷变为可见且可访问。

inactive
inactive
将基本MBR磁盘的焦点分区标记为非活动状态。请注意,如果分区是系统分区或引导分区,则计算机可能无法引导,直到磁盘再次标记为活动状态。
list
list disk
显示DiskPart可以访问的磁盘列表以及有关它们的信息。聚焦的磁盘上标有星号(*)。
list partition
显示聚焦磁盘上可访问分区的列表。在动态磁盘上,列出的分区可能与磁盘上的动态卷不完全对应。无法在动态磁盘上创建或删除分区。
list volume
显示安装在本地系统上的基本和动态卷的列表。
list vdisk
显示虚拟磁盘列表。在连接磁盘之前,磁盘类型将列为“未知”。所有具有焦点的磁盘均标有星号(*)。
merge
merge vdisk depth=n

将重点突出的子Hyper-V差异磁盘与其父虚拟磁盘合并。该深度可以使用参数,如果磁盘有多个家长,指定孩子有多深,应合并。

例如,depth = 2会将子级与其父级和祖父母合并。如果未指定,则默认深度为1,它将子级与其父级合并。

online
online disk [noerr]

使聚焦的脱机磁盘(处于脱机SAN模式)联机。如果磁盘是动态,只读和脱机磁盘,并且希望以读写模式使其联机,请首先启用读写模式,然后使磁盘联机。

脱机的只读动态磁盘如果联机,将报告错误,因为该操作需要写入磁盘上的动态磁盘数据库。

online volume [noerr]
使重点脱机卷联机。不适用于OEM,ESP或恢复分区。
offline
offline disk [noerr]
使聚焦的在线磁盘(在在线SAN模式下)脱机。不适用于OEM,ESP或恢复分区。
offline volume [noerr]
使关注的在线量脱机。
recover
recover [noerr]

刷新包中包含所选动态磁盘的所有磁盘的状态。此处,“磁盘包”是指在镜像或RAID-5配置中使用的一组动态磁盘。

恢复命令尝试重新同步在具有过时丛或奇偶校验数据的包的任何卷。

rem
rem [remark]
什么也不要做。使用rem在diskPart脚本中包含注释。
remove
remove [letter=d | mount={path|all}] [dismount] [noerr]

删除聚焦的卷的安装点,并有选择地卸载(卸载)该卷。如果信指定,驱动器字母d被移除时,或如果安装被指定时,所安装的路径名路径被移除。

如果全部指定,则删除该卷的所有安装点。“ 卸除”选项尝试卸除该卷,只有在删除所有装入点后才有可能。

无法删除系统卷或引导卷或包含活动页面文件的卷的安装点。

repair
repair disk=n [align=n] [noerr]

尝试通过将故障磁盘替换为另一个指定的磁盘来修复包含故障磁盘的聚焦RAID-5卷。必需的参数disk指定磁盘号n,以替换发生故障的磁盘。

备用磁盘的可用空间必须大于或等于故障磁盘的大小。如果指定align参数,则将卷扩展区对齐为n KB 的倍数,这可以提高使用LUN的硬件RAID配置的性能。

rescan
rescan
重新扫描计算机以查找可访问的磁盘和卷。
retain
retain
准备聚焦的动态简单卷以用作系统卷或引导卷。
san
san [policy={OnlineAll | OfflineAll | OfflineShared | OfflineInternal}] [noerr]

显示或设置当前引导的操作系统的SAN策略。如果不带任何参数,则显示当前的SAN策略。该政策参数可以指定设置SAN策略。

Windows Advanced Server和Windows数据中心的默认策略是OfflineShared,在该策略中,引导磁盘处于联机状态,所有磁盘均不在只读模式下位于共享总线上。

在所有其他版本的Windows上,默认策略为OnlineAll,其中所有磁盘以读写模式联机。

该OfflineAll策略指定,除了启动磁盘中的所有磁盘离线,并且是只读的默认。该OfflineInternal 该策略指定所有新发现的内部磁盘默认情况下保持脱机和只读状态。

select
select disk {n | system | next | path}

选择(聚焦)磁盘。该磁盘可以由磁盘编号n指定。

如果将磁盘指定为system,则在BIOS计算机上将BIOS磁盘0放在焦点上,或者在EFI机器上将包含ESP分区的磁盘放在焦点上。

如果将磁盘指定为next,并且当前有焦点在磁盘,则列表中的下一个磁盘将成为焦点。

select partition n
在当前聚焦的磁盘上选择(聚焦)分区n。
select volume={n | d}
选择(聚焦)音量。该卷可以通过卷号n或驱动器号或安装的文件夹路径名d来标识。例如,volume = 2,volume = C或volume = C:\ MyMount。
select vdisk file="filename" [noerr]
选择(聚焦)虚拟磁盘。使用file参数指定磁盘,其中filename是虚拟磁盘文件的完整路径和文件名。例如,file =“ C:\ vhd \ myVdisk.vhd”。
set
set id={byte|guid} [override] [noerr]

更改焦点分区的分区类型。请注意,此命令仅供OEM或IT专业人员使用。该类型由id参数指定。

如果它是MBR分区,则该类型是十六进制字节值,并且删除了前导0x,例如对于“无文件系统”为06。注意,不能使用此命令设置字节值42(LDM分区类型)。

如果分区是GPT分区,则可以使用GUID值设置类型,例如ebd0a0a2-b9e5-4433-87c0-68b6b72699c7用于“基本数据分区”。

注意,DiskPart不会检查字节或GUID以确保有效性,并且可以设置该值,即使该值无效或不正确也可能导致数据丢失。

如果您不是设备制造商或IT专业人员,请不要使用此命令。

设置分区类型的正确方法是在创建时。有关更多信息,请参见上面的create partition。 在DiskPart尝试更改分区类型之前,它会尝试锁定和卸载文件系统。

如果锁定和卸载失败,则不会设置分区类型,并且会报告错误。但是,如果指定了override,DiskPart会尝试强制卸载文件系统,即使不会正常卸载也是如此。 

命令setid是set id的别名。

shrink
shrink [desired=target] [minimum=min] [nowait] [noerr]

减小聚焦卷的最大大小,删除其中包含的部分或全部可用磁盘空间。如果未指定任何参数,则减小大小以消除所有可用空间。

如果指定了所需的内容,DiskPart将尝试缩小该卷,以便其新的总大小为目标兆字节。

如果指定了最小值,则DiskPart尝试将原始大小减小n兆字节。 请注意,某些文件(例如页面文件或卷影副本存储区域)有时无法重定位。

这些“不可移动”文件阻止DiskPart合并可用空间,这可能会干扰收缩过程。

如果收缩失败,请查看您的应用程序日志(在“ 事件查看器”中,单击Windows日志,然后是Application),并搜索事件259,

以标识导致收缩过程中止的不可移动文件。您可以通过重新配置页面文件来解决此问题。(在“文件资源管理器”中,右键单击“ 此PC或我的电脑”,

然后选择“ 属性”以打开“ 系统属性”。单击“ 高级系统设置”。在“ 高级”选项卡的“ 性能”部分中,单击“设置”。

在“ 高级”选项卡的“ 虚拟内存”部分中,单击“ 更改”)。

不可移动的卷影复制文件可以被重新配置,移动或删除(例如,用WMIC影拷贝,或在系统属性,在系统保护)。

shrink querymax [noerr]
显示可以从焦点卷中删除的最大字节数。显示的数量表示卷中当前可用的可用空间量。如果当前正在使用该卷,则该值可能会随着磁盘上的写入而变化。.
uniqueid
uniqueid disk [id={dword | guid}] [noerr]

显示或设置聚焦磁盘的GPT(GUID分区表)标识符或MBR(主引导记录)签名。如果未提供任何参数,则会显示聚焦磁盘的ID。

如果指定了id参数,那么对于MBR磁盘,ID设置为四字节的十六进制值dword,对于GPT磁盘,ID设置为GUID guid。

By default, if DiskPart encounters an error, it will terminate with a non-zero exit status.

Some DiskPart commands accept the noerr option. If noerr is specified, DiskPart ignores any errors encountered, 

and attempt to continue with subsequent operations. This option is a potentially dangerous, and should be used with caution.

 Command Subcommands, syntax, and description.
active active

Mark the selected partition as "active," indicating to your computer's BIOS or UEFI that this partition contains a bootable system. 

For example, the partition where Microsoft Windows is installed is an active partition. 

Note, only partitions on a basic disk (as opposed to a dynamic disk, such as a RAID array)can be marked active. 

Note, DiskPart does not actually check the contents of the partition to verify that it contains bootable system files.

add add disk=n [align=n] [wait] [noerr]

Create a mirror of the selected disk object at partition n, which must be a simple volume. 

Partition n must have unallocated space equal to or greater than the size of the selected volume, or the mirror cannot be created. 

If successful, the selected simple volume becomes a mirrored volume, with the mirror stored in partition n

Note, this command is not valid in Windows Vista.

assign assign [letter=d | mount=path] [noerr]

Assign a drive letter or mounted folder pathname to the selected volume. If no drive letter d or mounted folder path is specified,

the next available letter is assigned. If the drive letter or mounted folder is already in use, the operation fails and reports an error. 

Drive letters assigned to removable drives can be changed. 

You cannot assign drive letters to boot volumes, or volumes which contain the Windows paging file. 

You cannot assign a drive letter to an OEM partition (exception: Windows PE (pre-installation environment).

You cannot assign a drive letter to any GPT (GUID partition table) partition, other than a basic data partition. 

You cannot assign a drive letter to an ESP partition. 

You cannot assign a drive letter to a recovery partition.

attributes attributes disk [set | clear] [readonly] [noerr]

Set, clear, or display the attributes (flags) of the selected disk. The readonly flag indicates that the disk is write-protected (read-only).

If set is specified, the flag is set. If clear is specified, the flag is unset. If no options are given, the current disk flags are displayed. 

Disk flags other than "readonly" may be displayed, but cannot be set or cleared.

attributes volume [{set | clear}] [{hidden | readonly | nodefaultdriveletter | shadowcopy}] [noerr]

Set, clear, or display the attributes (flags) of the selected volume. The readonly flag indicates that the volume is write-protected. 

The hidden flag indicates that the volume should not be displayed in volume lists, e.g., in File Explorer. 

The nodefaultdriveletter flag indicates that the volume should not automatically be mounted and assigned a drive letter. 

The shadowcopy flag indicates that the volume is a shadow copy volume, used by the Windows VSS service. 

If set is specified, these flags are set. If clear is specified, these flags are unset. 

If no options are given, the current volume flags are displayed. 

On basic MBR disk, the hidden, readonly, and nodefaultdriveletter attributes always apply to all volumes on the disk. 

On basic GPT (GUID partition table) disks, dynamic MBR disks, and dynamic GPT disks, the attributes apply only to the selected volume.

attach attach vdisk [ readonly ] [sd=sddl-string] [usefilesd] [noerr]

Attaches (mounts) a VHD (virtual hard disk) or VHDX (Hyper-V virtual hard disk) file. The attached VHD appears as a local hard drive.

 If the VHD already has a disk partition with a valid file system, the virtual disk is as assigned a drive letter. If readonly is specified, 

the disk is mounted in read-only mode. If sd is specified, and sddl-string is a valid SDDL security descriptor string, 

that descriptor is applied to the entire disk. If usefilesd is specified, the security descriptor of the VHD file itself is applied to the entire disk. 

For more information about security descriptors, see create vdisk, below.

automount automount [enable | disable | scrub] [noerr]

Configure the AutoMount feature, which automatically mounts and assigns drive letters to disks that are newly attached to the system. 

If enable is specified, new disks will be automatically mounted, and assigned a drive letter and a volume GUID pathname. 

If disable is specified, this feature is disabled. 

If scrub is specified, any existing folder pathnames, drive letters, mounted folder directories, 

and registry settings are removed for volumes no longer connected to the system. 

Before Windows Vista, the AutoMount feature is available on basic disk volumes only. 

In Vista and newer versions, AutoMount is also available on dynamic disk volumes.

break break disk=n [nokeep] [noerr]

Break the selected mirrored volume into two simple volumes. Applicable to dynamic disks only. 

One of the simple volumes will retain the mirrored volume's assigned drive letter, GUID pathnames, and mounted folder paths, if any. 

The other volume is selected, so you can assign it a drive letter. 

When you do, a GUID pathname is automatically assigned. By default, both simple volumes retain the data of the original mirrored volume. 

If the nokeep option is specified, only one simple volume retains the data, and the other simple is cleared of data, and not selected.

clean clean [all]

Remove all partitioning and volume formatting from the selected disk. If all is specified, every byte on the disk is overwritten to zero, 

destroying any existing information on the entire disk. 

On MBR disks, only the MBR partitioning information and hidden sector information are overwritten. 

On GPT disks, in addition to the GPT information, the Protective MBR is overwritten. 

If all is omitted, only the first and last 1 MB of the disk is overwritten to zero. 

After a successful clean, the status of the disk is listed in DiskPart as "UNINITIALIZED."

compact compact vdisk

Attempt to reduce the size of the selected expandable VHD file. The VHD must be expandable for the operation to succeed. 

Even if a virtual disk is mounted as read-only, the VHD file can be compacted.

convert convert basic [noerr]

Convert the selected empty dynamic disk to a basic disk. All data on the selected disk must be deleted from the disk, 

and all its partitions and volumes deleted, or the operation fails.

convert dynamic [noerr]
Convert the selected basic disk to a dynamic disk. Any volumes on the disk become simple volumes.
convert gpt [noerr]

Convert the selected empty basic MBR disk to a basic GPT disk. All data on the selected disk must be deleted from the disk, 

and all its partitions and volumes deleted, or the operation fails.

convert mbr [noerr]

Convert the selected empty basic GPT disk to a basic MBR disk. All data on the selected disk must be deleted from the disk, 

and all its partitions and volumes deleted, or the operation fails.

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

Create an EFI (Extensible Firmware Interface) system partition on the focused basic GPT disk. 

The partition begins at the disk region offset from the beginning of the disk by n kilobytes if offset is specified, 

otherwise at the first available location on disk of adequate size. 

The size of the partition is n megabytes if size is specified, otherwise the partition uses all available space on that region of the disk. 

If the operation is successful, the new partition is focused.

create partition extended [size=n] [offset=n] [align=n] [noerr]

Create an extended partition on the focused basic MBR disk. 

Only one extended partition may exist on a disk (you can divide it into logical partitions later). 

The partition begins at n kilobytes if offset is specified, otherwise at the first available location of adequate size. 

The size is n megabytes if size is specified, otherwise it occupies all available space on disk beginning at its offset. 

If align is specified, the partition's offset will be rounded to a multiple of n kilobytes, 

which may improve performance when using a RAID configuration with LUNs (logical unit numbers).

create partition logical [size=n] [offset=n] [align=n] [noerr]

Create a logical partition in the extended partition of the focused basic MBR disk. 

The partition begins n kilobytes from the beginning of the extended partition if offset is specified, 

otherwise at the first available space in the extended partition. The size is n megabytes if size is specified, 

otherwise it uses all available space in the extended partition beginning at the offset.

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

Create an MSR (Microsoft reserved) partition on the focused GPT disk. The partition begins at n kilobytes if offset is specified, 

otherwise at first available location on disk. The size is n megabytes if size is specified, otherwise all available space is used. 

Use this command with extreme caution, because GPT disks have strict requirements for partition layout, 

and a layout which violates these rules may cause the disk to become unbootable. 

On GPT disks used to boot Windows, the EFI system partition must be the first partition on disk, 

followed immediately by the MSR partition. 

On GPT disks that do not have an EFI system partition (used for data storage only, no bootable OS on disk), 

the MSR partition must be the first partition on disk.

create partition primary [size=n] [offset=n] [id={byte|guid}] [align=n] [noerr]

Create a primary partition on the focused basic disk. The partition begins at n kilobytes if offset is specified, 

otherwise at the first available space on disk. The size is n megabytes if size is specified, 

otherwise all available space beginning at the offset is used. 

If align is specified, the offset will be rounded to a multiple of n kilobytes, 

which can improve performance on RAID configurations that use LUNs. 

The default partition type is "no filesystem" for MBR disks, or "basic data partition" for GPT disks.


When the partition is successfully created, it is automatically focused by DiskPart. 

A drive letter must manually be assigned with the assign command.

The partition type may be manually specified with the id option. Note that this option is intended for OEM use only. For MBR disks, 

the partition type byte is specified as a hexadecimal value with 

the leading 0x removed (e.g., 06 for "no filesystem," or 27 for "recovery partition"). For GPT disks, 

partition type is specified by a guid value (such as ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 for "basic data partition," 

or de94bba4-06d1-4d40-a16a-bfd50179d6ac for "recovery partition"). 

To see a list of recognized partition types, run help create partition primary.


Use caution when using the id option. The byte or guid value you specify will be set, even if it's unrecognized or incorrect. 

Incorrect use of the id option can cause the computer to become unbootable.

create volume raid [size=ndisk=n,n,n[,n[,...]] [align=n [noerr]

Create a raid-5 volume from three or more dynamic disks. The disks to be used must be specified with the disk parameter, 

with drive numbers separated by commas, e.g., disk=3,4,7 or disk=5,6,7,8. If align is specified, 

all volume extents are rounded to a multiple of n kilobytes, which may improve performance with a hardware RAID LUN configuration. 

When the operation succeeds, the new volume is automatically focused. 

Note that RAID-5 volumes are not supported in Windows Vista.

create volume simple [size=n] [disk=n] [align=n] [noerr]

Create a simple volume on the focused dynamic disk, or the disk specified with the disk parameter. 

Its size is n megabytes if size is specified, otherwise it uses all available space on the disk. 

If align is specified, the volume boundaries will be rounded to a multiple of n kilobytes, 

which can improve hardware RAID performance. When the volume is successfully created, the new volume is automatically focused.

create volume stripe [size=n] [disk=n,n,n[,n[,...]]] [align=n] [noerr]

Create a striped volume using two or more dynamic disks. 

The disk numbers must be specified by the disk parameter as a comma-separated list, e.g., 

disk=3,4 or disk=4,5,7. The size of the volume is n megabytes if size is specified, 

otherwise it uses the maximum free space on the smallest disk, 

and an equal amount of space on the other disks. 

If align is specified, volume boundaries are rounded to multiples of n kilobytes. 

When the volume is successfully created, it is automatically focused.

create volume mirror [size=ndisk=n,n,n[,n[,...]] [align=n] [noerr]

Create a mirror volume using two dynamic disks. The disks must be specified by number with disk, e.g., disk=2,3 or disk=3,5

The size of the partition is n megabytes if size is specified, otherwise it uses the remaining free space on the smaller disk, 

and an equal amount of space on the other. If align is specified, volume boundaries are rounded to a multiple of n kilobytes, 

which can improve performance in hardware RAID configurations that use LUNs. 

When the volume is successfully created, the new volume is automatically focused.

create vdisk file="filename" maximum=n [type={fixed|expendable}] [sd=sddl-string

[parent="parentfile"] [source="sourcefile"] [noerr]

Create a virtual disk file. The VHD and VHDX file formats are supported, and are specified by file extensions .vhd or .vhdx

The destination file name is specified with the required file parameter, 

where destfile is the complete path and file name of the destination virtual disk file, e.g., 

"C:\my-vdisk.vhd". The maximum parameter sets the maximum disk space exposed by the virtual disk to n megabytes. 

The type parameter specifies if the disk size is fixed (size can never be changed, default) or 

expandable (free space in the disk file can be expanded or compacted later).


If source is specified, the new virtual disk is populated with data from existing virtual disk sourcefile

If parent is specified, the virtual disk is created as a Hyper-V differencing disk, containing only the block data altered from parentfile

an existing virtual disk of the same size. The security descriptor of the virtual disk is set to match the parent directory of the destination file, 

or to the SDDL format string sddl-string if sd is specified. 

For details about valid SDDL strings, run help create vdisk.

delete delete disk [override] [noerr]

Delete the focused missing dynamic disk from the disk list. If override is specified, DiskPart deletes 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. 

An override fails if the disk is a member of a RAID-5 volume.

delete partition [override] [noerr]

Delete the focused basic disk partition. 

If it's a system partition, boot partition, or if it contains an active paging file or crash dump file, it cannot be deleted. 

Partitions on dynamic disks cannot be deleted.

delete volume [noerr]
Delete the focused volume. If it's a system volume, boot volume, or contains an active paging file or crash dump file, it cannot be deleted.
detail detail disk
Display the properties of the focused disk, and list its volumes.
detail partition
Display the properties of the focused partition.
detail volume
Display the properties of the focused volume, and list the disks on which the volume resides.
detail vdisk
Display the properties of the focused virtual disk.
detach detach vdisk [noerr]
Detach the specified virtual disk.
exit exit
Exit DiskPart.
extend extend [size=n] [disk=n] [noerr]

Extend the focused volume or partition, and optionally its file system, into unallocated space on a disk. 

The volume is expanded by n megabytes if size is specified, otherwise all available space is used. 

If disk is specified, and the focused volume or partition is a dynamic disk, the extension occurs on disk number n

otherwise, it occurs on the original disk. 

On basic disks, the expansion must always occur on the same disk, in space immediately following the original.


On dynamic disks with simple or spanned volumes, a volume can be extended to any free space on any dynamic disk. 

Mirrored, RAID-5, and striped volumes cannot be extended.


If the partition was previously formatted with NTFS, expand fails, and make no changes.
extend filesystem [noerr]

Extend the file system of an expanded volume or partition. 

Run this after the original expand command to expand the file system as well.

expand expand vdisk maximum=n

Expand the maximum size available on the focused virtual disk. 

The required maximum parameter sets the new total size to n megabytes. 

For example, maximum=30000 sets the new maximum size of the virtual disk to 30 gigabytes.

filesystems filesystems
Display information about the file system of the selected volume, and a list of supported file systems that can format it.
format

format [fs=fstype] [revision=X.XX] | [recommended] [label="label"]

 [unit=n] [quick] [compress] [override] [duplicate] [nowait] [noerr]

Format the focused volume. The file system fstype is used if fs is specified, 

otherwise the default file system listed by the filesystems command is used. 

If a specific revision of the file system is desired, it can be specified with revision

If label is specified, the volume label is set to label

If unit is specified, the default allocation unit size is overridden and set to n bytes. 

If quick is specified, a quick format is performed. 

If compress is specified and fs=NTFS, the NTFS file system will compress files by default. 

If override is specified, 

DiskPart attempts to force unmount the volume before formatting. 

If duplicate is specified and fs=UDF (Universal Disk Format) revision 2.5 or higher, 

file system metadata is duplicated to a second set of sectors on the disk (metadata redundancy). 

If nowait is specified, the command returns to the prompt immediately, and performs the format in the background.

gpt gpt attributes=n

Assign the specified GPT attributes to the focused partition on a basic GPT disk. 

This command is intended for OEM or IT professional use only. 

For detailed information about valid hexadecimal values of n, run help gpt.

help help [command] [subcommand ...]

Display a list of commands and subcommands with the syntax and descriptions. 

For example, helphelp helphelp create, or help create partition efi.

import import [noerr]

Import all disks in the same disk group as the focused foreign disk into the local computer's online disk group. 

A "foreign disk" is any dynamic disk installed locally that was previously used on another computer, 

or another version of Windows. 

After import, the dynamic disk volumes become visible and accessible.

inactive inactive

Mark the focused partition of a basic MBR disk as inactive. Note, if the partition is a system or boot partition, 

the computer may not be able to boot until the disk is marked active again.

list list disk

Display a list of disks that can be accessed by DiskPart, and information about them. 

The focused disk is marked with an asterisk (*).

list partition

Display a list of accessible partitions on the focused disk. 

On dynamic disks, partitions listed may not exactly correspond to the dynamic volumes on the disk. 

Partitions cannot be created or deleted on a dynamic disk.

list volume
Display a list of basic and dynamic volumes mounted on the local system.
list vdisk

Display a list of virtual disks. The disk type is listed as "unknown" until the disk is attached. 

Any disks with focus are marked with an asterisk (*).

merge merge vdisk depth=n

Merge the focused child Hyper-V differencing disk with its parent virtual disk. 

The depth parameter may be used if the disk has multiple parents, to specify how deeply the child should be merged. 

For instance, depth=2 would merge the child with its parent and grandparent. 

If not specified, the default depth is 1, which merges the child with its parent.

online online disk [noerr]

Bring the focused offline disk (in offline SAN mode) online. If the disk is dynamic, read-only, and offline, 

and you wish to bring it online in read-write mode, first enable read-write mode, then bring the disk online. 

n offline read-only dynamic disk will report an error if brought online, 

because the operation requires writing to the dynamic disk database on the disk.

online volume [noerr]
Bring the focused offline volume online. Not applicable to OEM, ESP, or recovery partitions.
offline offline disk [noerr]
Take the focused online disk (in online SAN mode) offline. Not applicable to OEM, ESP, or recovery partitions.
offline volume [noerr]
Take the focused online volume offline.
recover recover [noerr]

Refreshes the state of all disks in the pack which contains the selected dynamic disk. 

Here, "disk pack" refers to a set of dynamic disks used in a mirroring or RAID-5 configuration. 

The recover command attempts to resynchronize any volumes in the pack that have stale plex or parity data.

rem rem [remark]
Does nothing. Use rem to include comments in a DiskPart script.
remove remove [letter=d | mount={path|all}] [dismount] [noerr]

Remove mount points of the focused volume, and optionally dismount (unmount) the volume. 

If letter is specified, the drive letter d is removed, or if mount is specified, 

the mounted pathname path is removed. If all is specified, all mount points are removed for the volume. 

The dismount option attempts to unmount the volume, which is only possible if all mount points are removed. 

Mount points for system or boot volumes, or volumes containing an active paging file, cannot be removed.

repair repair disk=n [align=n] [noerr]

Attempt to repair the focused RAID-5 volume containing a failed disk, 

by replacing the failed disk with another, specified disk. 

The required parameter disk specifies the disk number, n, which is to replace the failed disk. 

The replacement disk must have free space greater than or equal to the size of the failed disk. 

If the align parameter is specified, volume extents are aligned to a multiple of n kilobytes, 

which can increase performance in hardware RAID configurations that use LUNs.

rescan rescan
Rescan the computer for accessible disks and volumes.
retain retain
Prepare the focused dynamic simple volume to be used as a system or boot volume.
san san [policy={OnlineAll | OfflineAll | OfflineShared | OfflineInternal}] [noerr]

Display or set the SAN policy for the currently booted operating system. 

With no parameters, the current SAN policy is displayed. 

The policy parameter may be specified to set the SAN policy. 

The default policy for Windows Advanced Server and Windows Data Center is OfflineShared

in which the boot disk is brought online and all disks not on a shared bus in read-only mode. 

On all other versions of Windows, the default policy is OnlineAll, in which all disks are brought online, in read-write mode. 

The OfflineAll policy specifies that all disks except the boot disk are taken offline, and are read-only by default. 

The OfflineInternal policy specifies that all newly discovered internal disks are kept offline and read-only by default.

select select disk {n | system | next | path}

Select (focus) a disk. The disk may be specified by disk number, n. If the disk is specified as system

on BIOS computers, BIOS disk 0 is focused, or on EFI machines, the disk containing the ESP partition is focused. 

If the disk is specified as next, and a disk currently has focus, the next disk in the list will be focused.

select partition n
Select (focus) partition n on the currently focused disk.
select volume={n | d}

Select (focus) a volume. The volume may be identified by volume number n, or by drive letter or mounted folder pathname d

For example, volume=2volume=C, or volume=C:\MyMount.

select vdisk file="filename" [noerr]

Select (focus) a virtual disk. The disk is specified with the file parameter, 

where filename is the complete path and file name of the virtual disk file. 

For example, file="C:\vhd\myVdisk.vhd".

set set id={byte|guid} [override] [noerr]

Change the partition type of the focused partition. Note, this command is intended for use by OEMs or IT professionals only. 

The type is specified with the id parameter. 

If it's an MBR partition, the type is a hexadecimal byte value with the leading 0x removed, e.g., 06 for "no filesystem." 

Note, the byte value 42 (LDM partition type) cannot be set with this command. If the partition is a GPT partition, 

the type can be set with a guid value, e.g., ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 for "basic data partition." 

Note, DiskPart does not check byte or guid for validity, and may set the value even if it's invalid or incorrect, 

which may cause data loss. Do not use this command if you are not an equipment manufacturer or IT professional. 

The proper way to set partition type is at creation time; see create partition, above, for more information.


Before DiskPart attempts to change the partition type, it attempts to lock and unmount the file system. 

If the lock and unmount fails, the partition type is not set, and an error is reported. 

However, if override is specified, DiskPart attempts to force-unmount the file system, even if it will not unmount gracefully.


The command setid is an alias for set id.
shrink shrink [desired=target] [minimum=min] [nowait] [noerr]

Reduce the maximum size of the focused volume, removing some or all the free disk space it contains. 

If no parameters are specified, the size is reduced to eliminate all free space. 

If desired is specified, DiskPart tries to shrink the volume so its new total size is target megabytes. 

If minimum is specified, DiskPart tries to reduce the original size by n megabytes.

Note, some files, for example the paging file or the shadow copy storage area, sometimes cannot be relocated. 

These "unmovable" files prevent DiskPart from consolidating the free space, which can interfere with the shrinking process. 

If the shrink fails, view your Application Logs (in Event Viewer, click Windows Logs then Application

and search for Event 259 to identify the unmovable file that aborted the shrink process. 

You may be able to resolve the issue by reconfiguring your paging file. (In File Explorer, right-click This PC or My Computer

and choose Properties to open the System Properties. Click Advanced system settings

In the Advanced tab, Performance section, click Settings. In the Advanced tab, Virtual memory section, click Change). 

Unmovable shadow copy files may be reconfigured, moved, or deleted (e.g., with wmic shadowcopy

or in System Properties, under System Protection).

shrink querymax [noerr]

Display the maximum number of bytes that can be removed from the focused volume. 

The amount displayed represents the amount of free space currently available in the volume. 

If the volume is currently in use, this value may vary as writes occur on the disk.

uniqueid uniqueid disk [id={dword | guid}] [noerr]

Displays or sets the GPT (GUID partition table) identifier or MBR (master boot record) signature of the focused disk. 

If no parameters are provided, the ID of the focused disk is displayed. 

If the id parameter is specified, the ID is set to the four-byte hexadecimal value dword for MBR disks, or to GUID guid for GPT disks.


以下大多数diskPart命令要求您选择磁盘或分区以使其具有“焦点”。要查看可以选择的磁盘和分区,请使用list命令。

Most of the following diskPart commands require you select a disk or partition to give it "focus." To view the disks and partitions that can be selected, use the list command.

查看英文版

查看中文版

diskPart 示例

要启动diskPart,请从“ 运行”框中或命令提示符处运行diskpart命令。在Windows 10之前的Windows版本中,该命令要求您以管理员身份运行命令提示符。在Windows 10中,如果diskpart由非管理员运行,请在UAC提示符下回答“ 是 ” 以继续。

diskpart

系统将显示DISKPART>提示符,您可以在其中运行diskPart命令。

DiskPart commands
list disk

列出可用的磁盘。样本输出:

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          476 GB   449 MB
  Disk 1    Online         2047 GB      0 B
  Disk 2    No Media           0 B      0 B
  Disk 3    No Media           0 B      0 B
  Disk 4    No Media           0 B      0 B
  Disk 5    No Media           0 B      0 B
select disk 0 

选择(聚焦)磁盘0。在聚焦磁盘上运行的后续命令将使用该磁盘。

现在,磁盘0是所选磁盘。

list partition

列出聚焦磁盘上的分区。样本输出:

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Primary            549 MB  1024 KB
  Partition 2    Primary            195 GB   550 MB
  Partition 0    Extended           269 GB   195 GB
  Partition 4    Logical             29 GB   195 GB
  Partition 5    Logical             29 GB   225 GB
  Partition 6    Logical              8 GB   254 GB
  Partition 7    Logical            202 GB   262 GB
  Partition 3    Recovery           502 MB   465 GB
select partition 1

在聚焦磁盘上选择(聚焦)分区1。

现在,分区1是所选分区。
detail partition

显示有关焦点分区的详细信息。样本输出:

Partition 1
Type  : 07
Hidden: No
Active: Yes
Offset in Bytes: 1048576
  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 0         System Rese  NTFS   Partition    549 MB  Healthy    System

To start DiskPart, run the diskpart command, from the Run box or a Command Prompt. In Windows versions previous to Windows 10, the command requires you run a Command Prompt as Administrator. In Windows 10, if diskpart is run by a non-administrator, answer Yes at the UAC prompt to proceed.

diskpart

You will be presented with the DISKPART> prompt, where you can run DiskPart commands.

DiskPart commands
list disk

List available disks. Sample output:

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          476 GB   449 MB
  Disk 1    Online         2047 GB      0 B
  Disk 2    No Media           0 B      0 B
  Disk 3    No Media           0 B      0 B
  Disk 4    No Media           0 B      0 B
  Disk 5    No Media           0 B      0 B
select disk 0 

Select (focus) Disk 0. Subsequent commands that operate on a focused disk use this disk.

Disk 0 is now the selected disk.
list partition

List the partitions on the focused disk. Sample output:

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Primary            549 MB  1024 KB
  Partition 2    Primary            195 GB   550 MB
  Partition 0    Extended           269 GB   195 GB
  Partition 4    Logical             29 GB   195 GB
  Partition 5    Logical             29 GB   225 GB
  Partition 6    Logical              8 GB   254 GB
  Partition 7    Logical            202 GB   262 GB
  Partition 3    Recovery           502 MB   465 GB
select partition 1

Select (focus) partition 1 on the focused disk.

Partition 1 is now the selected partition.
detail partition

Display detailed information about the focused partition. Sample output:

Partition 1
Type  : 07
Hidden: No
Active: Yes
Offset in Bytes: 1048576
  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 0         System Rese  NTFS   Partition    549 MB  Healthy    System

查看英文版

查看中文版