9

I am reading a 550MB file into /dev/null and I am getting

dd: writing '/dev/null': No space left on device

I was surprised. I thought /dev/null is a black hole where you can send as much as you want ( because its a virtual fs).

Yes my disk is almost full when I get this error. What can I do other than deleting content from the disk?

 ls -l /dev/null
 -rw-r--r--    1 root     root             0 July 7 21:58 /dev/null

Instead of

 crw-rw-rw-    1 root     root        1,   3 July 7 02:58 /dev/null

Command I am using:

time sh -c "dd if=$filename of=/dev/null"
5
  • 1
    Could you also copy/paste the dd command you're executing? Commented Aug 13, 2012 at 21:21
  • @forcefsck Done, added the command Commented Aug 13, 2012 at 21:32
  • what happens if you use time dd if="$filename" of=/dev/null? BTW. dd also outputs time elapsed. Commented Aug 13, 2012 at 21:39
  • 2
    This is indeed weird. Writing to /dev/null should never trigger this error, since it doesn't actually write anything anywhere. Do you get the same effect without time? Please post the output of strace dd if=$filename of=/dev/null (do it with a file containing no confidential information), or of strace dd if=$filename of=/dev/null if time is needed to trigger the error. Commented Aug 13, 2012 at 22:57
  • 1
    @Gilles Problem was that my /dev/null was not a character special file. I updated my question above. Commented Aug 13, 2012 at 23:21

1 Answer 1

19

/dev/null is a special file, of type character device. The driver for that character device ignores whatever you try to write to the device and writes are always successful. If a write to /dev/null fails, it means that you've somehow managed to remove the proper /dev/null and replace it by a regular file. You might have accidentally removed /dev/null; then the next … >/dev/null would have recreated it as a regular file.

Run ls -l /dev/null and check that the line looks something like

crw-rw-rw- 1 root root 1, 3 Sep 13  2011 /dev/null

It must begin with crw-rw-rw-: c for a character device, and permissions that allow everyone to read and write. The file should be owned by root, though it isn't very important. The two numbers after the owner and group identify the device (major and minor device number). Above I show the values under Linux; different unix variants have different values. The date is typically either the date when the system was installed or the date of the last reboot and doesn't matter.

If you need to recreate the file, some systems provide a MAKEDEV commmands, either in root's PATH or in /dev. Run cd /dev; ./MAKEDEV std or something like this to recreate the standard basic devices such as /dev/null. Or create the device manually, supplying the correct device numbers; on Linux, that's

mknod -m 666 /dev/null c 1 3
2
  • 1
    @Fr0zenFyr You probably have a script running as root that removes /dev/null in some circumstances, perhaps something like tmp_file=$(mktemp); … … … if [ "$mode" = "quiet" ]; then tmp_file=/dev/null; done; … … … rm "$tmp_file" Commented Jun 24, 2013 at 13:59
  • I'll have to check my scripts then, if this is true, there is a chance that null will be deleted again. I'll come back if i'm unable to locate(solve) this situation. Thanks for the heads up. Cheers!! :) Commented Jun 25, 2013 at 4:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.