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!
cat /dev/random
(orurandom
) give you?