I'm setting up some stuff - exactly what probably does not matter.

Anyhow I got an error from my application that indicated that /dev/random and /dev/urandom were needed but missing.

So I copied them over from a Linux build that had them, and then everything worked fine.

Is this OK? What problems might occur because I did this? If this is not oK, is there a "correct" way to create /dev/random and /dev/urandom?

  • What output does cat /dev/random (or urandom) give you? – Fiximan Nov 30 '16 at 22:30
  • @fiximan /dev/random at first gave a little bit of gunk like this: �_����3$�!� |�2�V�% and then stopped. /dev/urandom poured out similar gunk non stop. – Duke Dougal Nov 30 '16 at 22:33
  • At least it looks like expected behaviour. – Fiximan Nov 30 '16 at 22:35

To properly create the two devices, use:

mknod -m 444 /dev/random c 1 8
mknod -m 444 /dev/urandom c 1 9

/dev/random will generate high-entropy pseudorandom data. If entropy runs out, it will block until enough has been generated for new PRD.

/dev/urandom doesn't care about being sufficiently-high-entropy, which is by current cryptographic understanding not actually meaningful. The upshot is that urandom will not block during an entropy drought, but since sufficient entropy was used for the initial seed, the "weakness" in the randomness is purely theoretical at this point.


Yes, you can copy a /dev/random device. If the Linux filesystem you're taking them from has compatible definitions (same major and minor numbers), which it should, it will work.

You can't just use cp with no arguments, because that copies the random data and not the filesystem object. Use cp -a. (-a is the GNU option for "preserve everything").

Secondly, of course you have to be root, which it can be assumed you are if you're trying to create a /dev entry. If a regular user tries cp -a /dev/random foo, they are greeted with:

cp: cannot create special file `foo': Operation not permitted

If you have the permissions, cp -a it will create a duplicate of the special (character device) file.

Another way is just mknod. If we happen to know that the device major number for random is 1, and the minor number is 8, we can do

mknod foo c 1 8   # character device, major 1, minor 8

Now foo points to the same kernel device as /dev/random. Permissions are important also; when creating /dev entries, watch the perms; use the -m argument of mknod.

If copying /dev/random from an existing Linux filesystem tree with cp -a, it should hopefully have the right permissions (and of course ownership) already.

However, I would investigate why your system doesn't have these entries!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.