使用 tmpfs 挂载 ~/.cache 目录

使用 tmpfs 挂载 ~/.cache 目录

我使用的是 Ubuntu 15.04,我的主分区已加密。我尝试使用 tmpfs 来存储 .cache 目录。但不知道为什么它不起作用。这是我的 fstab

tmpfs /var/log/ tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=512M 0 0
tmpfs /home/prism/.cache/ tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=100M 0 0

但我的其余条目仍在运行。

答案1

您可以使用 /dev/shm (unix 上的默认 tmpfs 设备)

你可以在 ~/.xprofile 中做这样的事情:

#!/bin/sh
rm -rf /dev/shm/${USER}cache
mkdir /dev/shm/${USER}cache
chmod 700 /dev/shm/${USER}cache
rm -rf /home/${USER}/.cache
ln -s /dev/shm/${USER}cache /home/${USER}/.cache

相关内容