How to move temp files to RAM?

Hey,
I want to move my temp file system to ram to improve some performance in browsers, etc. How do I do it in simple way?

Usually it is by default.
tmpfs correlates to /tmp/

You can find out more here:
https://wiki.archlinux.org/index.php/Tmpfs

But it sounds like you particularly want your browser profile on tmpfs … which can be accomplished by
ASD or PSD:
https://wiki.archlinux.org/index.php/Profile-sync-daemon
https://wiki.archlinux.org/index.php/Anything-sync-daemon

Oh yeah … heres browser-specific articles:
https://wiki.archlinux.org/index.php/Firefox/Profile_on_RAM
https://wiki.archlinux.org/index.php/Chromium#Cache_in_tmpfs

You can make a small ramdisk and add this script to /etc/profile.d and make it executable.

# save in /etc/profile.d to make X programs like chromium/firefox remap cache directory to ramdisk

if [ $USER ]; then
  export XDG_CACHE_HOME="/path/to/ramdisk/${USER}/.cache"
fi

Wont that map everything that uses the variable for ‘user home .cache folder’ to tmpfs ?

Not saying it might not be desired … but it wont only affect ff/chrom, right?

True it remaps the whole .cache folder. I use it and it doesn’t cause me any issues.

I might not expect it to … probably depends … maybe some document service does its autosaves there and you rely on it … but it goes to tmpfs, so its lost on next reboot?

For me … I generally walk into that directory and swing a big sword whenever the mood is right.
So it probably wouldnt bother me either :grin:

I use PSD which is enough for FF, but chrom* I additionally put a line in fstab:

tmpfs   /home/USERNAME/.cache/chromium     tmpfs   noatime,nodev,nosuid,size=600M  0       0
3 Likes

I’ll keep that solution in mind. For Firefox I just edit about:config

I found that script on the web and mostly use it for the Chromium cache.

So basically I should add this line to /etc/fstab ?
tmpfs /tmp tmpfs rw,nodev,nosuid,size=2G 0 0

If you feel you need to set it manually.
Similarly you can use the tmp service, or configuration:
https://wiki.archlinux.org/index.php/Systemd#systemd-tmpfiles_-_temporary_files
https://wiki.archlinux.org/index.php/Tmpfs#Disable_automatic_mount

By default /tmp should already be tmpfs …

systemctl status tmp.mount

Oh you are right. It says tmp.mount is already active. So i don’t have to do anything more?

tmp is mounted as tmpfs by default (as half your ram)

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.