Azure ARM 模板允许为虚拟机指定数据磁盘,例如:
"dataDisks": [
{
"lun": 0,
"name": "[concat(variables('dataDiskName'), variables('nodesSuffixes')[copyIndex()])]",
"diskSizeGB": "[parameters('dataDiskSizeGB')]",
"createOption": "empty",
"managedDisk": {
"storageAccountType": "Standard_LRS"
}
}
]
在虚拟机上,此磁盘有时会变成sda
,有时变成sdc
,等等。
如何预测虚拟机中磁盘的名称?或者如何配置它以使其具有可预测的名称/dev/disk/by-*
答案1
在其中找到了一条规则,该规则创建了可用于 LVM 的/etc/udev/rules.d/
符号链接。可以在 ARM 模板中指定 LUN。/dev/disk/azure/scsi1/lun0
答案2
通常,当我们创建一个新的Azure VM时,VM的OS磁盘名称是/dev/sda
,临时磁盘名称是/dev/sdb
。
然后我们给这个虚拟机添加一个新的数据磁盘,默认情况下,新建数据盘名字将是/dev/sdc
。
无法指定数据盘的名称,也无法重命名。
root@jasonvmm:~# fdisk -l
Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x31520363
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 62914526 62912479 30G 83 Linux
Disk /dev/sdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf50fb2f3
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 104855551 104853504 50G 7 HPFS/NTFS/exFAT
Disk /dev/sdc: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdd: 60 GiB, 64424509440 bytes, 125829120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@jasonvmm:~#