磁盘 UUID 在哪个命名空间中是唯一的?

In what namespace is the disk UUID unique?

我已将连接有数据磁盘的备份还原到新 VM。当我发出命令 sudo blkid 时,我看到它与连接到原始 VM 的数据磁盘具有相同的 UUID,因此我不必更改 fstab 即可在引导时挂载它。但是,它似乎是一个物理上不同的磁盘,即我可以看到文件在连接到原始 VM 的磁盘上更新,但在恢复的 VM 上看不到。我认为 UUID 将是全球唯一的,但显然不是。那么它在什么命名空间中是唯一的?

磁盘的 UUID 对于新创建的 VM 始终是唯一的。但是当我们执行下面提到的操作时,UUID 不会保持唯一:

  1. 当我们复制 VM 的 VHD 时。
  2. 当我们使用 VM 映像部署新 VM 时。
  3. 当我们拍摄附有数据磁盘的图像时,OS 磁盘 UUID 将相同,我们必须制作附件的副本 UUID 也相同的磁盘。

你的情况是第三个选项,为此你必须创建数据磁盘的副本,如 Alexandre Brisebois in his blog 所述:

a copy of the Data Disks is required to keep the Data Disk UUIDs. Without these disks, a Virtual Machine created from the VM Image would result in a prompt a boot time. This prompt appears because the Virtual Machine is unable to find the Partition UUIDs that match the UUIDs from the fstab. Ultimately, this can result in a failed deployment and create can be challenging to troubleshoot and fix.

在您的情况下,预计文件将存储在原始 VM 的数据磁盘中,而不是还原的 VM 中。作为一种解决方案,您只能通过从 VM 分离数据磁盘来获取 OS 磁盘的映像,并在从映像部署新 VM 之后,您可以附加数据磁盘。