I want a /dev/null
directory, to which a graphical program can write a file, and think that it actually is writing it, like redirecting stdout to /dev/null
. I can't write it to /tmp
, as I nearly never reboot my system and that would make the hard disk full. I also don't want to delete the file afterwards.
1 Answer
The post How can I create a /dev/null-like "blackhole" directory? suggests this :
This isn't supported out-of-the-box on any unix I know, but you can do pretty much anything with FUSE. There's at least one implementation of nullfs, a filesystem where every file exists and behaves like
/dev/null
(this isn't the only implementation I've ever seen).
The post Is there a directory equivalent of /dev/null in Linux? has this much-upvoted answer:
The FHS provides no "standard" empty directory.
It is common for Linux systems to provide a directory
/var/empty
, but this directory is not defined in FHS and may not actually be empty. Instead, certain daemons will create their own empty directories in here. For instance, openssh uses the empty directory/var/empty/sshd
for privilege separation.If your need for an empty directory is transient, you can create an empty directory yourself, as a subdirectory of
/run
or/tmp
. If you're doing this outside the program, you can usemktemp -d
for this, or use themkdtemp(3)
C function inside your program. Though if you always need the empty directory to be present, consider creating one under/var/empty
as openssh does.For this use case, creating a directory under
/tmp
is probably the best fit, though in practice it doesn't matter very much where you put it.
-
Bang, nice find and reference there. Also how many bounty points you'd guess you've lost in just deleted accounts that have awarded you bounty? 100, 1000, 200 million. Jun 11 at 17:01
-
1Note that
/tmp
and/run
are typically mounted astmpfs
, which exists as a ramdisk. They can and will run out of space if you write large files into them, so they're not necessarily suitable as a throwaway directory for arbitrary programs (imagine if the program in question wanted to write images or videos?)– BobJun 12 at 8:14 -
yes. true. i wanted to write big files(gcode). still text but i dont want my ram draining 5gb.– jp_Jun 17 at 8:46
tmpreaper
, which is useful for cleaning up /tmp on systems that reboot seldom.