Ok so nothing you do on a tmpfs is not going to persist after a restart. That's because a tmpfs is temporary and only exists in the RAM. Anything that needs to be on a tmpfs for the system to run must be created every time the system boots. Most processes that use /var do this but some it seems such as anacron and cups-pdf do not.
To fix this you have to create a script that creates these directories every time the system starts. Copy the below into a text file, save it and make it executable.
# Script to create required directories in tempfs /var (that are not otherwise created)
# Thanks to http://blog.philippklaus.de/2011/02/ssd-optimizations-on-linux/ for the list below :-)
for dir in apparmor apt ConsoleKit cups dist-upgrade fsck gdm installer news ntpstats samba speech-dispatcher unattended-upgrades; do
if [ ! -d /var/log/$dir ] ; then
for dir in cups-pdf anacron; do
if [ ! -d /var/spool/$dir ] ; then
Next you need to make this script run every time the system starts by adding a line to /etc/rc.local
I called my script "make_required_dirs_on_tempfs.sh" so I just add the following line to the rc.local file. Put it at the end but above the "exit 0" command.
I saved my script in "/mnt/data/config/scripts/start-stop" and so my /etc/rc.local file looks like this:
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# By default this script does nothing.
#if [ -d "/var/cache/apt/archives" ]; then echo "/var/cache/apt/archives exists"; else mkdir /var/cache/apt/archives; fi || die "Command failed: mkdir /var/cache/apt/archives"