Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to move /tmp to RAM and obey good practice:

  • /var/tmp should NOT be placed in tmpfs, as it must survive reboots

  • not mount /tmp as a stand-alone tmpfs, but rely on /dev/shm or /run/shm

However, things have changed between 2.6 and 3.2 kernels :

Changes to the configuration and defaults of tmpfs filesystems

On 3.2 kernel, use RAMTMP=yes in /etc/default/tmpfs.

My question is: how can I achieve this goal with older kernels ?

My choice is nor to modify /etc/fstab neither this :

mkdir /dev/shm/tmp
chmod 1777 /dev/shm/tmp
mount --bind /dev/shm/tmp /tmp

Is there something like RAMTMP for 2.6 kernels ?

share|improve this question
tmpfs considered harmful. Food for thought. – sr_ Nov 15 '12 at 8:05
@sr_ Sorry, I strongly disagree with the linked article. /tmp can and should be used for temporary files, that's the whole point of it. /tmp is not supposed to survive a reboot (use /var/tmp for that) and who composes an email half the size of RAM+swap (without saving it)? – Marco Nov 15 '12 at 10:29
@Marco sure, I was just throwing in something I thought related. – sr_ Nov 15 '12 at 11:14

You don't have to do all that, you can just mount /tmp as tmpfs by using a line like the following in /etc/fstab:

tmpfs /tmp tmpfs mode=1777,nosuid,nodev 0 0

You can also do it live (but bear in mind stuff that is currently in /tmp on your current filesystem will not be able to be accessed except through the inode and currently open file descriptors, so you should really do this by modifying /etc/fstab and rebooting):

mount -o mode=1777,nosuid,nodev -t tmpfs tmpfs /tmp

Note that a tmpfs can swap. If you want a truly RAM-only filesystem, use ramfs.

share|improve this answer
Chris, my point is "best practices". The developers put native support to mount /tmp over .../shm; I read it is better to re-use the same tmpfs. – Massimo Nov 15 '12 at 0:27
@Massimo My opinion is that the best practise is not to bind mount. It adds unnecessary complexity. – Chris Down Nov 15 '12 at 0:28
@Massimo Where are you finding this 'best practices'? The only reason I can see against mounting /tmp as tmpfs is because you now have 2 potential tmpfs filesystems that can fill up and use more memory (/tmp and /dev/shm). But if you're really concerned about filling up 2 tmpfs mounts, you can decrease the maximum size of the tmpfs mount. – Patrick Nov 15 '12 at 1:52
@ChrisDown what is bad about bind mount? Also having a single tmpfs might make things simpler right? – CMCDragonkai Jun 5 '14 at 6:42
@CMCDragonkai Bind mounts are anything but simple internally, they come with quite a few unintuitive caveats that you probably don't intend (a particularly publicised one being the drama surrounding requiring remount for read-only mounts). Just use two tmpfs mounts instead. – Chris Down Jun 5 '14 at 7:00

/etc/default/tmpfs is for sysvinit, for systemd (Debian jessie default) you only need to do:

systemctl enable tmp.mount
share|improve this answer
Thanks! This is the right way to move /tmp to tmpfs in Jessie. – Yasiru G Jan 12 at 6:28
thank you so much! on gentoo i didn't understand why my /tmp is mounted tmpfs. the systemd script tmp.mount does it. – ufk Mar 11 at 9:42

I know this is rather old but in Debian-type distributions setting Set RAMTMP, RAMRUN and RAMLOCK in /etc/default/tmpfs (/etc/default/rcS or before wheezy) does the same job.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.