设置 id (Diskpart) set id (Diskpart)

适用于: Windows Server (半年通道) ,Windows Server 2019,Windows Server 2016,Windows Server 2012 R2,Windows Server 2012Applies to: Windows Server (Semi-Annual Channel), Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012

更改具有焦点的分区的 "分区类型" 字段。Changes the partition type field for the partition with focus. 此命令不适用于动态磁盘或 Microsoft 保留分区。This command doesn't work on dynamic disks or on Microsoft Reserved partitions.

重要

此命令仅供原始设备制造商 (Oem) 使用。This command is intended for use by original equipment manufacturers (OEMs) only. 更改具有此参数的分区类型字段可能导致计算机出现故障或无法启动。Changing partition type fields with this parameter might cause your computer to fail or be unable to boot. 除非你是使用 gpt 磁盘的 OEM 或经验丰富的磁盘,否则不应使用此参数更改 gpt 磁盘上的分区类型字段。Unless you are an OEM or experienced with gpt disks, you should not change partition type fields on gpt disks by using this parameter. 相反,请始终使用 create partition efi 命令创建 efi 系统分区,使用 create partition Msr 命令创建 Microsoft 保留分区,并使用 create partition PRIMARY 命令而不使用 ID 参数在 gpt 磁盘上创建主分区。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.

语法Syntax

set id={ <byte> | <GUID> } [override] [noerr]

parametersParameters

参数Parameter 说明Description
<byte> 对于主启动记录 (MBR) 磁盘,以十六进制格式为分区指定 "类型" 字段的新值。For master boot record (MBR) disks, specifies the new value for the type field, in hexadecimal form, for the partition. 除了指定 LDM 分区的类型0x42 以外,可以使用此参数指定任何分区类型 字节Any partition type byte can be specified with this parameter except for type 0x42, which specifies an LDM partition. 请注意,在指定十六进制分区类型时,将省略前导0x。Note that the leading 0x is omitted when specifying the hexadecimal partition type.
<GUID> 对于 GUID 分区表 (gpt) 磁盘,为分区的类型字段指定新的 GUID 值。For GUID partition table (gpt) disks, specifies the new GUID value for the type field for the partition. 可识别的 Guid 包括:Recognized GUIDs include:
  • EFI 系统分区: c12a7328-f81f-11d2-ba4b-00a0c93ec93bEFI system partition: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
  • 基本数据分区: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7Basic data partition: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
任何分区类型 GUID 都可与此参数一起指定,如下所示:Any partition type GUID can be specified with this parameter except the following:
  • Microsoft 保留分区: e3c9e316-0b5c-4db8-817d-f92df00215aeMicrosoft Reserved partition: e3c9e316-0b5c-4db8-817d-f92df00215ae
  • 动态磁盘上的 LDM 元数据分区: 5808c8aa-7e8f-42e0-85d2-e1e90434cfb3LDM metadata partition on a dynamic disk: 5808c8aa-7e8f-42e0-85d2-e1e90434cfb3
  • 动态磁盘上的 LDM 数据分区: af9b60a0-1431-4f62-bc68-3311714a69adLDM data partition on a dynamic disk: af9b60a0-1431-4f62-bc68-3311714a69ad
  • 群集元数据分区: db97dba9-0840-4bae-97f0-ffb9a327c7e1Cluster metadata partition: db97dba9-0840-4bae-97f0-ffb9a327c7e1
overrideoverride 强制在更改分区类型前卸除卷上的文件系统。forces the file system on the volume to dismount before changing the partition type. 当你运行 " 设置 id " 命令时,DiskPart 尝试锁定并卸除卷上的文件系统。When you run the set id command, DiskPart attempts to lock and dismount the file system on the volume. 如果未指定 override ,并且对锁定文件系统的调用失败 (例如,因为存在打开的句柄) ,则操作将失败。If override isn't specified, and the call to lock the file system fails (for example, because there is an open handle), the operation fails. 如果指定了 override ,则即使对锁定文件系统的调用失败,也会强制卸载,并且卷的任何打开的句柄都将停止生效。If override is specified, DiskPart forces the dismount even if the call to lock the file system fails, and any open handles to the volume will stop being valid.
noerrnoerr 仅用于脚本编写。Used for scripting only. 出现错误时,DiskPart 继续处理命令,就像未发生错误一样。When an error is encountered, DiskPart continues to process commands as if the error did not occur. 如果没有此参数,则错误会导致 DiskPart 退出并出现错误代码。Without this parameter, an error causes DiskPart to exit with an error code.

注解Remarks

  • 除了前面提到的限制之外,DiskPart 不会检查你指定的值的有效性 (除了确保它是十六进制格式的字节或 GUID) 。Other than the limitations previously mentioned, DiskPart doesn't check the validity of the value that you specify (except to ensure that it is a byte in hexadecimal form or a GUID).

示例Examples

若要将 "类型" 字段设置为 0x07 并强制卸除文件系统,请键入:To set the type field to 0x07 and force the file system to dismount, type:

set id=0x07 override

若要将 "类型" 字段设置为基本数据分区,请键入:To set the type field to be a basic data partition, type:

set id=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7

其他参考Additional References