Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from Nov 28 '12 at 19:04

This question came from our site for professional and enthusiast programmers.

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. – arkascha Nov 28 '12 at 16:40
up vote 3 down vote accepted

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).

share|improve this answer
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.

share|improve this answer

You must log in to answer this question.