How can I create a /dev/zero special file? Updated: 10/14/02


Prior to 11.11, HP-UX did not come with the special device file
/dev/zero.
However, it is possible to create one in 11.0 using the following
command:

# mknod /dev/zero c 3 4

Of course, use of the device file on an 11.0 system is unsupported by HP.

In conjunction with the dd command, /dev/zero can be used to fill a file
with a given number of the '\0' (nul) character. For example, to create a
1 MB file named "foo" full of nul characters, use the command:

$ dd bs=1024k count=1 if=/dev/zero of=foo

Note the same thing can be accomplished in 10.x using the prealloc(1)
command as follows:

$ prealloc foo 1048576

Note, filling a file with zeroes is not a secure way to wipe file data
from disk. For this, you must use a utility such as 'shred', which is
part of the GNU fileutils package.

A device file with slightly similar behavior to /dev/zero can be created
on 10.x as follows:

# mknod /dev/full c 3 3

Reading from this device will always succeed and report that the
requested number of bytes were read. However, no data will actually be
copied to the read buffer.



UNIXguide.net
Suggest a Site