6

I like this suggestion of mounting a tmpfs at /var/log in order to reduce disk writes.

Is there any way to do something similar for just a single file such as ~/.xsession-errors?


My incentive for asking comes from PowerTOP,

The program 'gnome-do' is writing to file '.xsession-errors' on /dev/sdb2.
This prevents the disk from going to powersave mode.

but one could also conceivably want to do this in order to speed up an IO-intensive program.

ændrük
  • 76,794

1 Answers1

5

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 /tmpor $TMPDIR filesystem is mounted from RAM, you're done.