No, there is no way you can force a single file not to be written to disk. Writes to a file are passed down to the filesystem code: if the filesystem is backed by memory (e.g., tmpfs
) then data is written to a (virtual) memory location; if the filesystem is backed by a block device (e.g., ext3/4) then data is written to the block device.
You can, however, symlink a specific file to a location in a tmpfs
filesystem; this will work as long as: (1) the destination of the symlink exists, and (2) the link is not removed and the file re-created in the original (disk-based) filesystem.
Concerning ~/.xession-errors
, there is some special treatment in /etc/X11/Xsession
(lines 63--72 as of x11-common
version 1:7.5+5ubuntu1): if ~/.xsession-errors
is already a symlink, then a temporary file (in directory $TMPDIR
or /tmp
) is used instead. So, if your /tmp
or $TMPDIR
filesystem is mounted from RAM, you're done.