how to get an unique machine ID for lxc

huky

Renowned Member
Jul 1, 2016
70
3
73
45
Chongqing, China
I want to get an unique machine ID for all host
but the command failed in lxc:

Code:
root@vlan50-62:~# dmidecode --string system-uuid
/sys/firmware/dmi/tables/smbios_entry_point: Permission denied
/dev/mem: No such file or directory

root@vlan50-62:~# dmidecode | grep -i uuid
/sys/firmware/dmi/tables/smbios_entry_point: Permission denied
/dev/mem: No such file or directory
root@vlan50-62:~# cat /sys/devices/virtual/dmi/id/product_uuid
cat: /sys/devices/virtual/dmi/id/product_uuid: Permission denied

root@node011:~# pct exec 100 cat /sys/devices/virtual/dmi/id/product_uuid
cat: /sys/devices/virtual/dmi/id/product_uuid: Permission denied

Is there other way?
 
hi,

you could use /etc/machine-id or /var/lib/dbus/machine-id

EDIT: sorry seems like these are also shared within templates.. but i'm guessing it can be modified?

anyway, the reason you get permission denied is that this file is non-namespaced and it's unique to your physical host. [0]

[0]: https://github.com/lxc/lxd/issues/4737