附加 vdiskattach vdisk

适用于: 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

将 (有时称为装载或表面) 虚拟硬盘 (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. 如果 VHD 在附加时已有磁盘分区和文件系统卷,则会为 VHD 中的卷分配一个驱动器号。If the VHD already has a disk partition and file system volume when you attach it, the volume inside the VHD is assigned a drive letter.

重要

您必须选择并分离 VHD 才能使此操作成功。You must choose and detach a VHD for this operation to succeed. 使用 " 选择 vdisk " 命令选择 VHD 并将焦点移动到该 VHD。Use the select vdisk command to select a VHD and shift the focus to it.

语法Syntax

attach vdisk [readonly] { [sd=<SDDL>] | [usefilesd] } [noerr]

参数Parameters

参数Parameter 说明Description
readonlyreadonly 将 VHD 附加为只读。Attaches the VHD as read-only. 任何写入操作都将返回错误。Any write operation returns an error.
sd=<SDDL string> 设置 VHD 上的用户筛选器。Sets the user filter on the VHD. 筛选器字符串必须采用安全描述符定义语言 (SDDL) 格式。The filter string must be in the Security Descriptor Definition Language (SDDL) format. 默认情况下,用户筛选器允许访问,就像在物理磁盘上。By default the user filter allows access like on a physical disk. SDDL 字符串可能比较复杂,但最简单的形式是,保护访问的安全描述符称为 (DACL) 的自由访问控制列表。SDDL strings can be complex, but in its simplest form, a security descriptor that protects access is known as a discretionary access control list (DACL). 它使用以下格式: D:<dacl_flags><string_ace1><string_ace2> .。。 <string_acen>It uses the form: D:<dacl_flags><string_ace1><string_ace2>... <string_acen>

常见的 DACL 标志包括:Common DACL flags are:

  • AA. 允许访问Allow access
  • D.D. 拒绝访问Deny access
常见权限包括:Common rights are:
  • GAGA. 所有访问All access
  • GRGR. 读取权限Read access
  • GWGW. 写入访问权限Write access
常见用户帐户包括:Common user accounts are:
  • BABA. 内置管理员Built in administrators
  • AUAU. 经过身份验证的用户Authenticated users
  • COCO. 创建者所有者Creator owner
  • WDWD. 所有人Everyone
示例:Examples:
  • D:P: (;;GR;;;AUD:P:(A;;GR;;;AU. 向所有经过身份验证的用户提供读取访问权限。Gives read-access to all authenticated users.
  • D:P: (;;GA;;;WDD:P:(A;;GA;;;WD. 为每个人提供完全访问权限。Gives everyone full access.
usefilesdusefilesd 指定应在 VHD 上使用 .vhd 文件上的安全描述符。Specifies that the security descriptor on the .vhd file should be used on the VHD. 如果未指定 Usefilesd 参数,则 VHD 将不具有明确的安全描述符,除非使用 Sd 参数指定它。If the Usefilesd parameter is not specified, the VHD will not have an explicit security descriptor unless it is specified with the Sd parameter.
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.

示例Examples

若要将所选 VHD 附加为只读,请键入:To attach the selected VHD as read-only, type:

attach vdisk readonly

其他参考Additional References