diskpartdiskpart

适用于: Windows 10,Windows 8.1,Windows 8,Windows 7,Windows Server 2019,Windows Server 2016,Windows Server 2012 R2,Windows Server 2012 和 Windows Server 2008 R2,Windows Server 2008Applies to: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012, and Windows Server 2008 R2, Windows Server 2008

Diskpart 命令解释器可帮助您 (磁盘、分区、卷或虚拟硬盘) 管理计算机驱动器。The diskpart command interpreter helps you manage your computer's drives (disks, partitions, volumes, or virtual hard disks).

你必须首先列出,然后选择一个对象来使其成为焦点,然后才能使用diskpart命令。Before you can use diskpart commands, you must first list, and then select an object to give it focus. 对象具有焦点后,你键入的任何 diskpart 命令都将作用于该对象。After an object has focus, any diskpart commands that you type will act on that object.

列出可用对象List available objects

可以使用以下方法列出可用对象,并确定对象的编号或驱动器号:You can list the available objects and determine an object's number or drive letter by using:

  • list disk-显示计算机上的所有磁盘。list disk - Displays all the disks on the computer.

  • list volume-显示计算机上的所有卷。list volume - Displays all the volumes on the computer.

  • list partition-显示在计算机上有焦点的磁盘上的分区。list partition - Displays the partitions on the disk that has focus on the computer.

  • list vdisk-显示计算机上的所有虚拟磁盘。list vdisk - Displays all the virtual disks on the computer.

运行列表命令后,星号 ( * ) 将显示在具有焦点的对象旁边。After you run the list commands, an asterisk (*) appears next to the object with focus.

确定焦点Determine focus

选择对象时,焦点一直停留在该对象上,直至选择其他对象。When you select an object, the focus remains on that object until you select a different object. 例如,如果焦点设置在磁盘0上,并且选择了磁盘2上的卷8,则焦点将从磁盘0转移到磁盘2、卷8。For example, if the focus is set on disk 0 and you select volume 8 on disk 2, the focus shifts from disk 0 to disk 2, volume 8.

某些命令会自动更改焦点。Some commands automatically change the focus. 例如,在创建新的分区时,焦点会自动切换到新的分区。For example, when you create a new partition, the focus automatically switches to the new partition.

只能将焦点放到所选磁盘上的分区。You can only give focus to a partition on the selected disk. 分区具有焦点后,如果任何) 也有焦点,则相关卷 (。After a partition has focus, the related volume (if any) also has focus. 如果卷具有焦点,则相关磁盘和分区也会获得焦点,前提是该卷映射到单个特定分区。After a volume has focus, the related disk and partition also have focus if the volume maps to a single specific partition. 如果不是这样,则对磁盘和分区的关注会丢失。If this isn't the case, focus on the disk and partition is lost.

语法Syntax

若要启动 diskpart 命令解释器,请在命令提示符下键入:To start the diskpart command interpreter, at the command prompt type:

diskpart <parameter>

重要

你必须是本地管理员组或具有类似权限的组才能运行 diskpart。You must be in your local Administrators group, or a group with similar permissions, to run diskpart.

参数Parameters

可以从 Diskpart 命令解释器运行以下命令:You can run the following commands from the Diskpart command interpreter:

CommandCommand 描述Description
activeactive 将具有焦点的磁盘分区标记为活动分区。Marks the disk's partition with focus, as active.
addadd 将选中的简单卷镜像到指定磁盘。Mirrors the simple volume with focus to the specified disk.
assignassign 给选中的卷分配一个驱动器号或装入点。Assigns a drive letter or mount point to the volume with focus.
附加 vdiskattach vdisk 将 (有时称为装载或表面) 虚拟硬盘 (VHD) ,使其作为本地硬盘驱动器出现在主计算机上。Attaches (sometimes called mounts or surfaces) a virtual hard disk (VHD) so that it appears on the host computer as a local hard disk drive.
attributesattributes 显示、设置或清除磁盘或卷的属性。Displays, sets, or clears the attributes of a disk or volume.
automountautomount 启用或禁用自动装载功能。Enables or disables the automount feature.
breakbreak 将选中的镜像卷分为两个简单卷。Breaks the mirrored volume with focus into two simple volumes.
cleanclean 从选中的磁盘中删除所有分区或卷格式。Removes any and all partition or volume formatting from the disk with focus.
compact vdiskcompact vdisk 减小动态扩展虚拟硬盘 (VHD) 文件的物理大小。Reduces the physical size of a dynamically expanding virtual hard disk (VHD) file.
convertconvert 将 (FAT) 和 FAT32 卷的文件分配表转换为 NTFS 文件系统,从而使现有文件和目录保持不变。Converts file allocation table (FAT) and FAT32 volumes to the NTFS file system, leaving existing files and directories intact.
createcreate 在磁盘上创建分区,在一个或多个磁盘上创建卷,或在虚拟硬盘 (VHD) 上创建分区。Creates a partition on a disk, a volume on one or more disks, or a virtual hard disk (VHD).
deletedelete 删除分区或卷。Deletes a partition or a volume.
detach vdiskdetach vdisk 停止所选虚拟硬盘 (VHD) 在主计算机上显示为本地硬盘驱动器。Stops the selected virtual hard disk (VHD) from appearing as a local hard disk drive on the host computer.
detaildetail 显示有关所选磁盘、分区、卷或虚拟硬盘 (VHD) 的信息。Displays information about the selected disk, partition, volume, or virtual hard disk (VHD).
exitexit 退出 diskpart 命令解释器。Exits the diskpart command interpreter.
expand vdiskexpand vdisk 将虚拟硬盘 (VHD) 展开为指定的大小。Expands a virtual hard disk (VHD) to the size that you specify.
extendextend 将具有焦点的卷或分区连同其文件系统一起扩展到磁盘上的可用 (未分配) 空间。Extends the volume or partition with focus, along with its file system, into free (unallocated) space on a disk.
filesystemsfilesystems 显示具有焦点的卷的当前文件系统的相关信息,并列出格式化卷时支持的文件系统。Displays information about the current file system of the volume with focus and lists the file systems that are supported for formatting the volume.
formatformat 格式化磁盘以接受 Windows 文件。Formats a disk to accept Windows files.
gptgpt 将) (的 gpt 属性分配给分区,并将焦点放在基本 GUID 分区表 (gpt) 磁盘上。Assigns the gpt attribute(s) to the partition with focus on basic GUID partition table (gpt) disks.
helphelp 显示有关指定命令的可用命令或详细帮助信息的列表。Displays a list of the available commands or detailed help information on a specified command.
importimport 将外部磁盘组导入到本地计算机的磁盘组。Imports a foreign disk group into the disk group of the local computer.
inactiveinactive 在基本主启动记录上将具有焦点的系统分区或启动分区标记为非活动状态 (MBR) 磁盘。Marks the system partition or boot partition with focus as inactive on basic master boot record (MBR) disks.
listlist 显示磁盘中的磁盘分区的列表、磁盘中的卷的列表,或者显示 (Vhd) 的虚拟硬盘的列表。Displays a list of disks, of partitions in a disk, of volumes in a disk, or of virtual hard disks (VHDs).
merge vdiskmerge vdisk 将差异虚拟硬盘 (VHD) 与其相应的父 VHD 合并。Merges a differencing virtual hard disk (VHD) with its corresponding parent VHD.
offlineoffline 使联机磁盘或卷进入脱机状态。Takes an online disk or volume to the offline state.
onlineonline 使脱机磁盘或卷处于联机状态。Takes an offline disk or volume to the online state.
recoverrecover 刷新磁盘组中所有磁盘的状态,尝试恢复无效磁盘组中的磁盘,并重新同步已过时的镜像卷和 RAID-5 卷。Refreshes the state of all disks in a disk group, attempt to recover disks in an invalid disk group, and resynchronizes mirrored volumes and RAID-5 volumes that have stale data.
remrem 提供一种向脚本添加注释的方法。Provides a way to add comments to a script.
删除remove 从卷中删除驱动器号或装入点。Removes a drive letter or mount point from a volume.
repairrepair 通过将故障磁盘区域替换为指定的动态磁盘,修复具有焦点的 RAID-5 卷。Repairs the RAID-5 volume with focus by replacing the failed disk region with the specified dynamic disk.
rescanrescan 查找可能已添加到计算机的新磁盘。Locates new disks that may have been added to the computer.
retainretain 准备要用作启动卷或系统卷的现有动态简单卷。Prepares an existing dynamic simple volume to be used as a boot or system volume.
sansan 显示或设置操作系统的存储区域网络 (san) 策略。Displays or sets the storage area network (san) policy for the operating system.
selectselect 将焦点移到磁盘、分区、卷或虚拟硬盘 (VHD) 。Shifts the focus to a disk, partition, volume, or virtual hard disk (VHD).
set idset id 更改具有焦点的分区的 "分区类型" 字段。Changes the partition type field for the partition with focus.
shrinkshrink 按指定的数量减小所选卷的大小。Reduces the size of the selected volume by the amount you specify.
uniqueiduniqueid 显示或设置 GUID 分区表 (GPT) 标识符或主启动记录 (MBR 的主) 签名。Displays or sets the GUID partition table (GPT) identifier or master boot record (MBR) signature for the disk with focus.

其他参考Additional References