Increase the 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, let’s investigate, then make a few adjustments to maximize the life of your SSDs and SD cards. This article has been refreshed from seven years ago.
Table of Contents
Using iotop to monitor and minimize reads/writes
Use your Linux distro’s package manager to install iotop, a top-like utility for disk I/O. It monitors disk I/O usage information output by the Linux kernel 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, making it easy to identify processes hogging your disk I/O. Take a look at the screenshot below as an example.
See MySQL tuning and PHP performance tips. You cannot eliminate all disk I/O, especially for services like MySQL and PHP (pictured above). What you are looking for are processes hogging disk I/O without good reason. Below are additional tips for avoiding some common disk overhead.
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 being read. Since writes are more expensive, this often results in measurable performance gains.
Here’s what this line should look like in /etc/fstab:
/dev/sdx / ext4 noatime,errors=remount-ro 0 1
Mount temporary directories as 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
2025 update: Modern Linux distributions now mount /tmp
as tmpfs by default. If your system doesn’t already do this, and you have enough memory, you can still mount additional directories like /var/tmp
as tmpfs to reduce disk writes.
Avoid heavy use of Swap Space
This is a recommended tweak for SSDs and SD cards on systems using a swap partition (guide to setting swappiness). This will reduce the “swappiness” of your system, thus reducing disk swap I/O. On Debian/Ubuntu (or Red Hat/CentOS), add or modify the following in /etc/sysctl.conf (or the equivalent config file).
# Decrease swap usage
vm.swappiness=1
If you have adequate free memory and understand the risks, you can avoid adding swap altogether or use this instead. Also, read Does your Linux server need a RAM upgrade?
# Disable swap usage
vm.swappiness=0
You can also automate swap only to be enabled when necessary using systemd-swap.
Also, see zram-generator or zram-swap.
2025 update: Reducing swap usage is good to limit unnecessary writes on SSDs. But if your system uses an NVMe SSD, the higher endurance and faster speeds make this less of a concern. For more flexibility, you can also consider zram or zswap to manage swap space in memory and reduce physical disk writes.
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
For journalctl, you can tweak this in /etc/systemd/journald.conf.
Edit the following lines accordingly (read descriptions and size format):
Storage= SystemMaxUse= SystemKeepFree= SystemMaxFileSize= RuntimeMaxUse= RuntimeKeepFree= RuntimeMaxFileSize= MaxLevelStore=
Mount additional directories with heavy I/O to tmpfs
For example, mount the busy I/O directory to tmpfs:
tmpfs /full/path/to/busy/io/dir/ tmpfs defaults, size=1G 0 0
profile-sync-daemon (for desktop only)
If you’re not optimizing a web server and use Firefox, Chrome, etc., 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 periodically sync it back to your physical disc (HDD/SSD).
2025 Update: With cloud-based browser syncing and more RAM in modern systems, this isn’t as important as it used to be.
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 Hat/CentOS, Debian/Ubuntu)
2025 Update: Modern Linux kernels default to schedulers like MQ-Deadline or BFQ which are optimized for SSDs. So now, in most cases, you don’t need to manually change the I/O scheduler.
TRIM
2025 note: TRIM is crucial for SSD performance, but most SD cards don’t support TRIM. Make sure you’re applying these checks only to devices where TRIM is applicable. While the discard option in /etc/fstab enables TRIM, it’s not recommended for all cases. Many modern Linux distros now use scheduled fstrim runs to handle TRIM more efficiently and minimize performance overhead during regular use. Consider using fstrim instead of the discard mount option, as the latter can hurt performance on some setups.
If not already enabled by default. 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 can write data to blocks without performing the cumbersome deletion process. In essence, TRIM ensures that your SSD’s performance doesn’t degrade too much with use.
First, check your /etc/fstab
file to confirm that you have the discard
option set for your SSD.
To check if your SSD or SD card supports TRIM, use the following:
sudo hdparm -I /dev/sdx | grep "TRIM supported"
To check if TRIM is enabled, use the following:
sudo systemctl status fstrim.timer
The result will look like this if enabled:
● fstrim.timer - Discard unused blocks once a week
Loaded: loaded (/usr/lib/systemd/system/fstrim.timer; enabled; vendor preset: disabled)
Active: active (waiting) since Wed 2021-05-12 14:52:42 AST; 58s ago
Trigger: Mon 2021-05-17 00:35:19 AST; 4 days left
Triggers: ● fstrim.service
Docs: man:fstrim
May 12 14:52:42 alien systemd[1]: Started Discard unused blocks once a week.
To enable use:
sudo systemctl enable fstrim.timer sudo systemctl start fstrim.timer
FAT32/ExFAT for SD Cards
SD cards use FAT32 or ExFAT file systems, which lack TRIM and journaling. For applications that require frequent writes, consider a card with higher endurance or switch to a Linux compatible file system like ext4 if possible.
Filesystems
Modern filesystems like Btrfs and ext4 are fine with SSDs, but each has its quirks. Btrfs has compression and snapshots, which can help with storage efficiency but may increase write activity. Check your workload before choosing a filesystem.
NVMe Drives
NVMe SSDs are the norm now, way faster and more endurance than SATA SSDs. Make sure your system is set up to use them and consider enabling fstrim.timer
to keep performance optimal.
Further increasing performance/life of SSDs & SD Cards
Use larger SD cards: Writes are spread based on the storage size, so the larger the storage, the less it will repeatedly rewrite over the same areas = less wear.
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/sdxx
For NVMe drives, use nvme-cli
which is designed for modern NVMe devices:
sudo nvme smart-log /dev/nvmeX
Related articles
- What is iowait and how does it affect Linux performance?
- Linux server performance: Is disk I/O slowing your application?
- Free vs. Available Memory in Linux
Published: Jan 30th, 2018 | Last updated: January 29th, 2025
What is considered the average lifespan of an SSD that has files on it but is not being used?
Good question. SSDs have come a long way since originally publishing this article.
The lifespan is not absolute. But modern and good quality SSDs will work well for 10+ years.
And sitting unused for at least 10 to 15 years. Maybe longer but that’s risky.
Of course, there are variables such as climate (temperature, humidity, salt air, etc), load/usage, brand/quality, etc. etc.
I’ve been using a pair Samsung EVO SSDs in RAID 0, for the past 8 years without a single issue:
How common is it for an SSD to die due to a power outage?
I had been considering getting a UPS for this very reason because I am paranoid that the power might kill my SSDs if the power goes. I have at least 3 or 4 per year where I live and it almost always happens when I have my computer running.
Generally, your concern here is with the filesystem on the SSD, not with the SSD itself. Most modern filesystems can tolerate hard power losses but it’s likely that you will lose at least some data in the process (could be ephemeral data, could be “real” files). If you’re having 3-4 power failures per year, it’s probably a good idea to get that UPS; can’t hurt. If possible, it might be a good idea as well to set your OS up to recognize the power outage and gracefully come down within the UPS’s hold time.
This article has been updated. A lot has changed since 2018, so I’ve added notes for 2025+.