如何将 Azure 磁盘映射到 Linux VM 来宾磁盘How to map Azure Disks to Linux VM guest disks

你需要确定支持 VM 来宾磁盘的 Azure 磁盘。You may need to determine the Azure Disks that back a VM's guest disks. 在某些方案中,可以将磁盘或卷大小与附加的 Azure 磁盘的大小进行比较。In some scenarios, you can compare the disk or volume size to the size of the attached Azure Disks. 如果有多个相同大小的 Azure 磁盘附加到 VM,则需要使用数据磁盘的逻辑单元号 (LUN)。In scenarios where there are multiple Azure Disks of the same size attached to the VM you need to use the Logical Unit Number (LUN) of the data disks.

什么是 LUN?What is a LUN?

逻辑单元号 (LUN) 是用于标识特定存储设备的数字。A Logical Unit Number (LUN) is a number that is used to identify a specific storage device. 会为每个存储设备分配一个唯一的数字标识符(从零开始)。Each storage device is assigned a unique numeric identifier, starting at zero. 设备的完整路径由总线编号、目标 ID 号和逻辑单元号 (LUN) 表示。The full path to a device is represented by the bus number, target ID number, and Logical Unit Number (LUN).

例如,总线编号 0,目标 ID 0,LUN 3For example: *Bus Number 0, Target ID 0, LUN 3 _

在我们的练习中,只需要使用 LUN。For our exercise, you only need to use the LUN.

查找 LUNFinding the LUN

下面列出了两种在 Linux 中查找磁盘 LUN 的方法。Below we have listed two methods for finding the LUN of a disk in Linux.

lsscsilsscsi

  1. 连接到 VMConnect to the VM
  2. sudo lsscsi

列出的第一列将包含 LUN,格式为 [Host:Channel:Target:*LUN**]。The first column listed will contain the LUN, the format is [Host:Channel:Target:*LUN**].

列出块设备Listing block devices

  1. 连接到 VMConnect to the VM
  2. sudo ls -l /sys/block/*/device

列出的最后一列将包含 LUN,格式为 [Host:Channel:Target:LUN]The last column listed will contain the LUN, the format is [Host:Channel:Target:LUN]

查找 Azure 磁盘的 LUNFinding the LUN for the Azure Disks

可以使用 Azure 门户、Azure CLI 查找 LUN。You can locate the LUN for an Azure Disk using the Azure portal, Azure CLI.

在 Azure 门户中查找 Azure 磁盘的 LUNFinding an Azure Disk's LUN in the Azure portal

  1. 在 Azure 门户中,选择“虚拟机”以显示虚拟机的列表In the Azure portal, select "Virtual Machines" to display a list of your Virtual Machines
  2. 选择虚拟机Select the Virtual Machine
  3. 选择“磁盘”Select "Disks"
  4. 从附加的磁盘列表中选择一个数据磁盘。Select a data disk from the list of attached disks.
  5. 磁盘的 LUN 显示在“磁盘详细信息”窗格中。The LUN of the disk will be displayed in the disk detail pane. 此处显示的 LUN 与使用 lsscsi 在来宾中查找的 Lun 相关联,或列出了块设备。The LUN displayed here correlate to the LUNs that you looked up in the Guest using lsscsi, or listing the block devices.

使用 Azure CLI 查找 Azure 磁盘的 LUNFinding an Azure Disk's LUN using Azure CLI

az vm show -g myResourceGroup -n myVM --query "storageProfile.dataDisks"