Increase Performance and lifespan of SSDs & SD Cards

SSDs (solid-state drives) and SD (Secure Digital) cards have a limited number of writes before they wear out. To get the most out of this storage type lets investigate, then make a few adjustments to maximize the life of your SSDs and SD cards.

Using iotop to monitor and minimize reads/writes

Use can your Linux distro’s package manager to install iotop which is a top like utility for disk I/O. It monitors disk I/O usage information output by the Linux kernel (2.6.20+) and displays a table of current usage by processes on the system. Use iotop with the following options:

iotop -oPa

Then let iotop monitor things for a few mins or hours depending on how intense disk I/O is. This will result in a top-like screen which makes it easy to identify processes that are hogging your disk’s reads or writes.  Have a look at the screenshot below from my Ubuntu-based laptop optimized for SDD storage. I used the iotop -oPa command and let it sit for 30 mins in the background:


noatime Mount Flag

Using the noatime mount flag in the /etc/fstab file stops the logging of read access times to the file system. The noatime mount flag eliminates the need for the system to make timestamp writes for files which are simply being read. Since writes are more expensive this often results in measurable performance gains.

Related:  TrueAbility Linux Showdown 8

Here’s what this line looks like in my /etc/fstab:

/dev/sda1        /              ext4    discard,noatime,errors=remount-ro   0       1

Temporary directories as a tmpfs

If your system has enough memory, you can mount some temporary directories as a tmpfs. This reduces unnecessary writes to the SSD. Again edit /etc/fstab:

# SSD tweak: temporary directories as tmpfs
tmpfs   /tmp       tmpfs   defaults,noatime,mode=1777   0 0
tmpfs   /var/tmp   tmpfs   defaults,noatime,mode=1777   0 0

Avoid heavy use of Swap Space

This is a recommended tweak for SSDs and SD cards based systems using a swap partition, it will reduce the “swappiness” of the system thus avoiding writes to swap.  On Ubuntu (and Red Hat, CentOS) add or modify the following in /etc/sysctl.conf.

# Decrease swap usage

If you have lots of free RAM and understand the risks, you can avoid adding swap completely, or just use this instead:


Reduce logging writes

Disable access logs for Apache, Nginx, mail server and other services you have installed. Once your system is stable, you can reduce system log levels from info, to warn or even error OR if you don’t mind losing log files between boots move them to tmpfs by editing /etc/fstab:

tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0

Mount even more directories with heavy I/O to tmpfs

For example mount the WordPress cache directory from disk to tmpfs:

tmpfs /full/path/to/wp-content/cache tmpfs defaults, size=1G 0 0


If you’re not optimizing a web server and you use Firefox, Chrome, etc., then install the profile-sync-daemon. The Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage your browser’s profile in tmpfs and to periodically sync it back to your physical disc (HDD/SSD).

Related:  Analyze Your Website's TTFB (Time to First Byte)

Disable journaling on an ext4 filesystem

You will have to unmount the file system partition first. Backup before attempting this. Then use the following command:

tune4fs -O ^has_journal /dev/sdXY
e4fsck –f /dev/sdXY
sudo reboot

 I/O Scheduler

Consider switching from the CFQ to NOOP or Deadline. Both offer better performance on SSDs and SD cards.

Check which scheduler you are using with the following command (replace sdX):

cat /sys/block/sdX/queue/scheduler

Change the scheduler by adding the kernel parameter “elevator=noop”. (Red HatUbuntu)


TRIM allows Linux to inform the SSD which blocks of data are no longer considered in use. Therefore, when you delete a file, your SSD is now able to write data to blocks as if it they were brand new without having to perform the cumbersome deletion process. In essence, TRIM makes sure that your SSD’s performance doesn’t degrade too much with use.

Check if your SSD or SD card supports TRIM:

sudo hdparm -I /dev/sda | grep "TRIM supported"

If it does, then add TRIM as a daily cron job:

echo -e "#\x21/bin/sh\\nfstrim -v /" | sudo tee /etc/cron.daily/trim

Make the cron job executable using:

sudo chmod +x /etc/cron.daily/trim

This will run every day to avoid slowing down your writes.

EDIT: Using a Linux distribution which supports TRIM by default (ex. Ubuntu 14.04) is very helpful, but not a fix-all. Reducing reads/writes still goes a long way!

Related:  CVE-2014-6271: Vulnerability in Bash allows remote execution of arbitrary code

Further increase performance and life of SSDs & SD Cards

— Use larger SD cards. Writes are spread based on the size of storage, so the larger the card, the less it will repeatedly write over the same areas… less wear. 16GB, 32GB or even 64GB SD cards.
— You get what you pay for. Cheap SSDs and SD cards usually will not last as long or perform as fast.
— Use this command to check for issues and lifespan:

sudo smartctl -a /dev/sda

Tags: , , ,