Skip to content

How to: Reduce Disk Writes to Prolong the Life of your Flash Drive

Please note: This customization is not included in Ubuntu Eee 8.04 by default.

Move /tmp, /var/log and /var/log/apt into RAM

[Note: This is not needed on EasyPeasy, only for stock Ubuntu]

Using the fstab file we can move temporary data and log files into RAM. This process mounts each location as a temporary file system.

sudo gedit /etc/fstab

Add the following lines to the bottom of your fstab file.

tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0 
tmpfs /var/log/apt tmpfs defaults,noatime 0 0

Note: As per the Filesystem Hierarchy Standard for Linux, /var/tmp should NOT be placed in tmpfs:

“The /var/tmp directory is made available for programs that require temporary files or directories that are preserved between system reboots. Therefore, data stored in /var/tmp is more persistent than data in /tmp. Files and directories located in /var/tmp must not be deleted when the system is booted. Although data stored in /var/tmp is typically deleted in a site-specific manner, it is recommended that deletions occur at a less frequent interval than /tmp.”

Wicd 1.5 users: Do not add the last 2 lines otherwise the Wicd daemon will fail to start. This is a known Wicd bug.

To determine which version of Wicd (if any) you have, type the following command:

dpkg -s wicd

Note: Your log files will vanish after each reboot. But other than that, there are no harmful side effects from this operation.

You might add also unionfs for /var/cache at the end of fstab:

none /var/cache unionfs dirs=/tmp:/var/cache=ro 0 0

Tweak Primary File Systems

The following options can be added to your remaining partitions to help lower disk writes:

  • Use the “noatime,nodiratime” options for any of your reiserfs partitions in /etc/fstab. This also gives slightly faster filesystem performance.
  • Use the noatime option for any of your ext3 partitions in /etc/fstab. See Geek Sheet’s blog for more details.
  • Use the non-journalling filesystem ext2 at the cost of slower fsck’s. and mtab

The following commands can be executed to further reduce disk writes. If you wish to mount anything through fuse the second set of instructions will likely cause problems, if you go ahead and later need to mount something, instructions for removal of this link can be found on the talk page for this article.

sudo rm -f /etc/*
sudo ln -s /dev/null /etc/
sudo rm -f /etc/mtab
sudo ln -s /proc/mounts /etc/mtab

See Debian Administration for more details.

Optimize Firefox Cache

Note: Each user will have to perform this operation when logged in for it to affect them.

Launch Firefox and enter about:config into the URL bar and press enter. Right click and select New > String; enter browser.cache.disk.parent_directory as the name and /tmp as the string value. This will instead store the cache in RAM (if you followed the first operation in this article.)

Alternatively you can set the cache to 0Mb on the Network tab of the Advanced section in the Firefox preferences. This may cause slow performance on EEEs with less than 512Mb of RAM.

I also found browser.cache.disk.enable key. It might be enough to set it to false.

Optimize Apt Archives

  1. sudo chmod u+x /etc/rc.local
  2. add following line into /etc/fstab
    tmpfs /var/cache/apt/archives/ tmpfs defaults,noatime 0 0
  3. add following line into /etc/rc.local
    mkdir /var/cache/apt/archives/partial

All deb package will be downloaded into ramfs, and keep in mind not to make to much upgrade at one time to save ram space, usually 512MB should be enough for most install and upgrade.

3.7/5 - (3 votes)

Leave a Reply

Your email address will not be published. Required fields are marked *