使用 D: 盘作为 Windows VM 上的数据驱动器Use the D: drive as a data drive on a Windows VM

如果应用程序需要使用 D 盘存储数据,请按照以下说明使用其他驱动器号作为临时磁盘。If your application needs to use the D drive to store data, follow these instructions to use a different drive letter for the temporary disk. 切勿使用临时磁盘来存储需要保存的数据。Never use the temporary disk to store data that you need to keep.

如果调整虚拟机大小或停止(解除分配) 虚拟机,这可能会触发将虚拟机放置于新虚拟机监控程序的操作。If you resize or Stop (Deallocate) a virtual machine, this may trigger placement of the virtual machine to a new hypervisor. 计划中或计划外的维护事件也可能触发此放置操作。A planned or unplanned maintenance event may also trigger this placement. 在这种情况下,临时磁盘将重新分配给第一个可用的驱动器号。In this scenario, the temporary disk will be reassigned to the first available drive letter. 如果应用程序明确需要 D: 盘,则需要遵循以下步骤暂时移动 pagefile.sys,并连接新的数据磁盘并为其分配驱动器号 D,再将 pagefile.sys 移回到临时驱动器。If you have an application that specifically requires the D: drive, you need to follow these steps to temporarily move the pagefile.sys, attach a new data disk and assign it the letter D and then move the pagefile.sys back to the temporary drive. 完成后,如果 VM 移到不同的虚拟机监控程序,Azure 不会收回 D:。Once complete, Azure will not take back the D: if the VM moves to a different hypervisor.

有关 Azure 如何使用临时磁盘的详细信息,请参阅 了解 Azure 虚拟机上的临时驱动器For more information about how Azure uses the temporary disk, see Understanding the temporary drive on Azure Virtual Machines

附加数据磁盘Attach the data disk

首先,需要将数据磁盘附加到虚拟机。First, you'll need to attach the data disk to the virtual machine. 若要使用门户执行此操作,请参阅如何在 Azure 门户中附加托管数据磁盘To do this using the portal, see How to attach a managed data disk in the Azure portal.

将 pagefile.sys 暂时移到 C 驱动器Temporarily move pagefile.sys to C drive

  1. 连接到虚拟机。Connect to the virtual machine.
  2. 右键单击“开始”菜单,并选择“系统”。Right-click the Start menu and select System.
  3. 在左侧菜单中,选择“高级系统设置”。In the left-hand menu, select Advanced system settings.
  4. 在“性能”部分中,选择“设置”。In the Performance section, select Settings.
  5. 选择“高级”选项卡。Select the Advanced tab.
  6. 在“虚拟内存”部分中,选择“更改”。In the Virtual memory section, select Change.
  7. 选择 C 盘,并依次单击“系统管理的大小”、“设置”。Select the C drive and then click System managed size and then click Set.
  8. 选择 D 盘,并依次单击“无分页文件”、“设置”。Select the D drive and then click No paging file and then click Set.
  9. 单击“应用”。Click Apply. 你会收到警告,指出计算机需要重新启动才能使更改生效。You will get a warning that the computer needs to be restarted for the changes to take affect.
  10. 重启虚拟机。Restart the virtual machine.

更改驱动器号Change the drive letters

  1. VM 重新启动后,重新登录到 VM。Once the VM restarts, log back on to the VM.
  2. 单击“开始”菜单,键入 diskmgmt.msc,并按 Enter。Click the Start menu and type diskmgmt.msc and hit Enter. 此时会启动“磁盘管理”。Disk Management will start.
  3. 右键单击 D(临时存储驱动器),并选择“更改驱动器号和路径”。Right-click on D, the Temporary Storage drive, and select Change Drive Letter and Paths.
  4. 在“驱动器号”下,选择一个新驱动器,如 T,并单击“确定”。Under Drive letter, select a new drive such as T and then click OK.
  5. 右键单击数据磁盘,并选择“更改驱动器号和路径”。Right-click on the data disk, and select Change Drive Letter and Paths.
  6. 在“驱动器号”下,选择驱动器 D,并单击“确定”。Under Drive letter, select drive D and then click OK.

将 pagefile.sys 移回临时存储驱动器Move pagefile.sys back to the temporary storage drive

  1. 右键单击“开始”菜单,并选择“系统”。Right-click the Start menu and select System
  2. 在左侧菜单中,选择“高级系统设置”。In the left-hand menu, select Advanced system settings.
  3. 在“性能”部分中,选择“设置”。In the Performance section, select Settings.
  4. 选择“高级”选项卡。Select the Advanced tab.
  5. 在“虚拟内存”部分中,选择“更改”。In the Virtual memory section, select Change.
  6. 选择 OS 驱动器 C,并依次单击“无分页文件”、“设置”。Select the OS drive C and click No paging file and then click Set.
  7. 选择临时存储驱动器 T,并依次单击“系统管理的大小”、“设置”。Select the temporary storage drive T and then click System managed size and then click Set.
  8. 单击“应用” 。Click Apply. 你会收到警告,指出计算机需要重新启动才能使更改生效。You will get a warning that the computer needs to be restarted for the changes to take affect.
  9. 重启虚拟机。Restart the virtual machine.

后续步骤Next steps