Mount /tmp as ramdisk

If you have enough RAM you can use it to store temporary file. To mount /tmp as a ramdisk add the follwing line to your /etc/fstab:

none /tmp tmpfs defaults 0 0

Of course you have to edit the file as root. After that reboot or mount it manually. I used the following line:

sudo rm -rf /tmp/*; sudo mount -a

Attention!! This removes all files under /tmp from your disk and mounts all devices mentioned in /etc/fstab. So make sure there are no critical tasks if you use both commands.

After mounting /tmp it is hard to get red of it again if programs use it. You can find out who uses it with

lsof | grep /tmp

Then you have to close all programs that use it before you can unmount it. Otherwise you’ll get “device busy” errors.

Leave a Reply