Ubuntu: Reduce SSD Disk wear

Posted by Andreas Schmidt on Sep 29, 2009 in Linux, Ubuntu |

Ubuntu: Howto reduce the SSD wear

Open fstab, and add the following lines:

# sudo gedit /etc/fstab

tmpfs /var/log tmpfs defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
tmpfs /var/tmp tmpfs defaults 0 0

There is currently a bug in sysklogd where it cannot handle booting with an empty /var/log directory (bug #290127). This can be fixed by modifying /etc/init.d/sysklogd:

Find this function:

fix_log_ownership()
for l in `syslogd-listfiles -a`
do
chown ${USER}:adm $l
done
}

..and replace it with this:

fix_log_ownership()
{
for l in `syslogd-listfiles -a –news`
do
# Create directory for logfile if required
ldir=$(echo ${l} | sed ‘s/[^\/]*$//g’)
if [ ! -e $ldir ] ; then
mkdir -p $ldir
fi
# Touch logfile and chown
touch $l && chown ${USER}:adm $l
done
}

Warning: this will cause some packages to fail mysteriously when they cannot access the log directories that were installed with the packages and then disappeared at reboot.

To rebuild the rest of the directory structure inside /var/log on each reboot, add these lines to /etc/rc.local above the ‘exit 0′ line:

for dir in apparmor apt ConsoleKit cups dist-upgrade fsck gdm installer news ntpstats samba unattended-upgrades ; do
if [ ! -e /var/log/$dir ] ; then
mkdir /var/log/$dir
fi
done

Tags: , ,

Copyright © 2009-2010 The Solaris Cookbook All rights reserved.
Desk Mess Mirrored v1.4.6 theme from BuyNowShop.com.