attach vdisk

附加(有时称为装载或显露 (surface))虚拟硬盘 (VHD),使其在主机计算机上显示为本地硬盘驱动器。 如果你在附加 VHD 时 VHD 已具有磁盘分区和文件系统卷,则系统会为 VHD 内的卷分配一个驱动器号。

Important

必须选择并分离 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
readonly 系统将以只读方式附加 VHD。 任何写入操作都会返回错误。
sd=<SDDL string> 在 VHD 上设置用户筛选器。 筛选器字符串必须采用安全描述符定义语言 (SDDL) 格式。 默认情况下,用户筛选器允许像在物理磁盘上一样进行访问。 SDDL 字符串可能很复杂,但在最简单的形式中,保护访问的安全描述符称为自由访问控制列表 (DACL)。 SDDL 使用的格式为:D:<dacl_flags><string_ace1><string_ace2>... <string_acen>

常见的 DACL 标志包括:

  • A. Allow access
  • D. Deny access
常见权限包括:
  • GA. All access
  • GR. Read access
  • GW. Write access
常见的用户帐户包括:
  • BA. 内置管理员
  • AU. Authenticated users
  • CO. Creator owner
  • WD. Everyone
Examples:
  • D:P:(A;;GR;;;AU. 向所有经过身份验证的用户授予读取访问权限。
  • D:P:(A;;GA;;;WD. 为每个人提供完全访问权限。
usefilesd 指定应在 VHD 上使用 .vhd 文件上的安全描述符。 If the Usefilesd parameter is not specified, the VHD will not have an explicit security descriptor unless it is specified with the Sd parameter.
noerr 仅用于编写脚本。 出现错误时,DiskPart 继续处理命令,就像未发生错误一样。 如果没有此参数,则错误会导致 DiskPart 退出并显示错误代码。

Examples

若要以只读方式附加所选 VHD,请键入:

attach vdisk readonly