I’m trying to sample some randomness as early as possible in the boot process on Ubuntu. I was wondering if anyone has suggestions how to do that. My current idea is to look for the place where /dev/random and /dev/urandom are created in the boot sequence, and add my code there.
Thanks!
The files /dev/random and /dev/urandom are created by the device manager as a part of the hardware abstraction layer. This is managed as part of udev and systemd (according to wikipedia, systemd had udev merged into it in April of 2012).
You can check the startup order of this service with the command
After it starts, those files should be available.
The other thing you can do if you need a random number earlier than that is have your program/script get the epoch time, and use that, or if you need a range, use a modulus of your upper random number range to get a number from 0 – your modulus. That should work at any time. How to do it will depend on your language.