Reduce Flash Writes

From PlugWiki

Jump to: navigation, search

The following are suggestions to reduce the number of writes to the Flash file system and extend the life of the Plug Flash memory

Contents

Reduce Swapping

To see the current setting

#cat /proc/sys/vm/swappiness

To set:

# echo 0 >/proc/sys/vm/swappiness

To make the change permanent add the following line to /etc/sysctl.conf

vm.swappiness=0

Enable Laptop Mode

Laptop mode works by submitting all future pending disk IO at once.

To see if laptop mode is enabled run

# cat /proc/sys/vm/laptop_mode

Use this command to enable laptop mode

# echo 5 > /proc/sys/vm/laptop_mode

To make the change permanent add the following line to /etc/sysctl.conf

vm.laptop_mode=5

Reduce Cache Writeback TIme

You can check the current value of this writeback time with these commands:

# cat /proc/sys/vm/dirty_writeback_centisecs
# cat /proc/sys/vm/dirty_expire_centisecs

Increase the time to 15 seconds with the following commands:

echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
echo 1500 > /proc/sys/vm/dirty_expire_centisecs

To make the change permanent add the following line to /etc/sysctl.conf

vm.dirty_writeback_centisecs=1500
vm.dirty_expire_centisecs=1500

Filesystem relatime

relatime works by updating the atime field on disk only if the file hasn't been accessed since the last time it was accessed

A discussion of the relatime option can be found at http://lwn.net/Articles/244829/.

Change /etc/fstab to

rootfs / rootfs relatime,rw 0 0 

Reduce syslog file syncing

syslogd will in the default installation sync a lot of log files to disk directly after logging some new information. You might want to change /etc/syslog.conf so that every filename starts with a - (minus) which means that writes are not synced immediately (which increases the risk that some log messages are lost if your system crashes). For example, a line such as:

kern.*                          /var/log/kern.log

would be changed to

kern.*                          -/var/log/kern.log


On Debian, you may be using rsyslog, in which case, add the following to /etc/rsyslog.conf

$ActionFileEnableSync on

Sources

http://www.lesswatts.org/tips/disks.php

http://www.cyrius.com/debian/nslu2/linux-on-flash.html

Personal tools