/dev/null missing, how can I replace?

5

How can I replace /dev/zero or /dev/urandom? I'd like to zero out the freespace of a headless server that doesn't have either /dev/zero or /dev/urandom (or /dev/random) nor does this machine have access to the internet. Is it possible to scp a special file like /dev/zero?

Russell

Posted 2012-11-28T16:37:16.057

Reputation:

It makes no sense at all to copy /dev/zero with scp. That is just a node in the file system, there is nothing special or magic about that. It is just like a name. – None – 2012-11-28T16:40:57.473

Answers

3

Special files like devices can be stored in tar files.

It is also possible to use the mknod command to create these files given the type, major, and minor numbers of the device file. This information appears in the output of ls -l.

For example, on my system:

crw-rw-rw- 1 root root 1, 5 Nov 25 16:44 /dev/zero

Thus, mknod /dev/zero c 1 5 could be used to recreate /dev/zero. (This may not be correct for your system; major and minor numbers are subject to change).

nandhp

Posted 2012-11-28T16:37:16.057

Reputation: 191

5

mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/random c 1 8
mknod /dev/urandom c 1 9

would work on my system.

The numbers (major/minor ID) might be subject to change, however.

glglgl

Posted 2012-11-28T16:37:16.057

Reputation: 1 327