I am trying to move /tmp
to RAM and obey good practice:
-
/var/tmp
should NOT be placed intmpfs
, as it must survive reboots -
not mount
/tmp
as a stand-alonetmpfs
, 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 ?
Best Answer
You don't have to do all that, you can just mount
/tmp
astmpfs
by using a line like the following in/etc/fstab
: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):Note that a
tmpfs
can swap. If you want a truly RAM-only filesystem, useramfs
.