Sorry for the interruption but I find this interesting. This means that, for example, if I have a very slow hd, and I want to improve access to some files I write to very often, can I mount a dir of my liking as a tmpfs and drop files in it?
First let me say that for Nightflyer's system, mount /var as a tmpfs would not be advisable -- I lost track of what he was trying to accomplish (/var as tmpfs would only be preferable if he only had CF for permanent storage). I imagine Nightflyer is aware of this but wished to correct my mistake.
Rbistolfi, tmpfs is very nice for the situation you describe, particularly if you do a lot of modifications to the files before you need to commit them. In some situations, however, Linux's native caching handles things just as efficiently (when there is a lot of data being accessed multiple times, but not being modified).
As an example, I do a bit of video editing using the GIMP Animation Package. This program works by treating a video as a sequence of separate image files and a 3-minute video might be 20,000 files. When I apply a filter, for example, each of those files gets loaded into the GIMP, the filter applied, and the file written back to disk. Each modification I make requires this loading and saving of the files. By creating a tmpfs directory and copying all of the files to it, I see about a four-fold increase in speed (and a lot less disk wear). After I am done, of course, I need to move the edited files to the harddrive.
Personally, I don't like to keep these tmpfs directories around too long because they detract from the kernel's caching and swapping abilities (I don't have oodles of RAM). But they are a powerful tool in certain scenarios and they certainly would seem to obviate the need for ever creating a fixed-size "ramdisk".
I also like your idea about adding a USB stick for swap. Since it will rarely or never be used, it could be low speed/capacity. This should not affect performance of the system and be cheap insurance?
I have always liked having some
swap available, regardless of how much RAM I have. If it is never used, no big loss. However, if a program has a memory leak that eventually uses up all your system RAM, at least when you start thrashing your swap you will have time to take graceful corrective measures (ie, kill the offending process) and avoid a random shutdown of some unrelated program/daemon. Cheap insurance, indeed.