Good filesystem for /tmp?

I sometimes find moving /tmp to ram (tmpfs) is the best solution (Especially on my setups which use a lot of disk intensive IO stuff - MySQL, etc) if you have enough RAM to feed it.


There are several good choices here:

  1. tmpfs: is a filesystem which stores its files in RAM. This doesn't mean that the filesystem will eat all your RAM. Instead it takes only the amount it really needs. Usually only some MB are needed. If you'll use it, add a line like: none /tmp tmpfs size=64M,mode=1777 0 0 to your /etc/fstab. You can change the size to a value you like. If you think at some point that it is too little, you can use mount to increase the size: mount -t tmpfs tmpfs /tmp -o size=128M,mode=1777,remount. The size will be increased in place without deleting existing files.
  2. ext2/3: You said in your question that you don't need any fancy features. However I would advise using a journal. Because if you use ext2 and you have a quite large /tmp, checking it will take some time. ext3 boots faster in many cases. Therefore I would suggest the use of journalling.
  3. ext4, reiserfs etc.: Some software uses /tmp for storing large amounts of small files. So in some cases there are no more free blocks and the filesystem is full. ext4 and also reiserfs store files in a different way. So it could be a good choice to use those for your /tmp.

If your computer runs for a long time, it is a good idea to delete unused files in /tmp. tmpreaper is one solution which does that for you.

However my first choice would be using tmpfs.


If you don't want it possibly eating RAM, I'd just run it as ext2. No reason to eat the small performance hit of journaling for a filesystem whose data you don't (shouldn't) care about across reboots.

Actually, scratch that, you should probably use ext4 and disable its journal, it should be faster than ext2. Format it ext4, and stick it in fstab with the mount option data=writeback.

Tags:

Tmp

Filesystem