How to move the user cache directory [~/.cache] out of the /home directory to another partition

The .cache directory is full of volatile, non-essential files.

I would like to move it to a more appropriate partition, i.e. faster and not backed up.

I believe that ~/.pam_environment file is appropriate for this but am not sure if is the best or if it is documented properly or working properly.

2

1 Answer

If you don't care about keeping the stuff there across reboots, you can use tmpfs to store the cache.

Set something like the following in /etc/fstab:

tmpfs /home/someuser/.cache tmpfs defaults,size=512M 0 0

Now, your .cache will be stored in memory instead of on disk, though if you have insufficient memory it could end up being swapped out.

A more traditional approach would be to move the directory to wherever you like and symlink it as appropriate:

mv ~/.cache /some/other/place
ln -s /some/other/place/.cache ~/
6

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like