Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
    
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
add comment

migrated from stackoverflow.com Nov 28 '12 at 19:04

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

2 Answers

up vote 2 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
add comment
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.