我需要通过发送他们唯一的ID来注册监视目的Linux服务器在真实硬件以及虚拟机,AWS,Azure等上运行。我想出了
给出的idsudo dmidecode | grep UUID
是最佳选择,因为即使您在没有重新初始化MAC地址的情况下克隆了虚拟机,其结果也会有所不同。
但 dmidecode 并未随处安装。所以我试图了解文件 / sys / devices / virtual / dmi / id / product_uuid 始终包含与 dmidecode
答案 0 :(得分:1)
dmidecode | grep UUID
和/sys/devices/virtual/dmi/id/product_uuid
应该相等,但根据您的系统,输出可能会有所不同。
来自dmidecode source code:
/*
* As of version 2.6 of the SMBIOS specification, the first 3
* fields of the UUID are supposed to be encoded on little-endian.
* The specification says that this is the defacto standard,
* however I've seen systems following RFC 4122 instead and use
* network byte order, so I am reluctant to apply the byte-swapping
* for older versions.
*/
另请参阅:[PATCH] dmi, Use little-endian for sysfs PRODUCT UUID
我注意到Ansible也首先尝试/ sys并回退到dmidecode可执行文件以收集与dmi相关的事实。