Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting linux system UUID which changes after reboot

Tags:

linux

I'm looking for a linux system session id which is constant over the full runtime of the linux session (as long as uptime is increasing). After each reboot, it should be reset to another (random) value, probably formatted as a uuid.

I need this for logging in a global context, where I need to know if two logfiles come from the same session. Placing a stamp file in /tmp/ or another volatile folder could be an option but I want to avoid flooding such global folders. Using the system startup time is also not an option because the machine doesn't have an RTC battery and the time is reset after power loss. There will still be some milliseconds difference each time, but I don't want to risk collisions. Same thing with hashing the system start dmesg or parts of /proc or /sys.

I wonder if the kernel doesn't already provide such information over /proc or /sys?

like image 662
Daniel Alder Avatar asked May 24 '26 13:05

Daniel Alder


1 Answers

The solution:

cat /proc/sys/kernel/random/boot_id

I found it while searching for systemd's "boot id". There was a DBus bug report referencing the file: https://bugs.freedesktop.org/show_bug.cgi?id=23679

like image 95
Daniel Alder Avatar answered Jun 01 '26 09:06

Daniel Alder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!