I have been using Intel 520 SSD 180GB on my Dell Inspiron 11z-1121 laptop for a while and get great speed. However, if you want to tweak and optimize your Linux SSD for Ubuntu, Linux Mint, Debian or any linux distribution to make your SSD run even faster and live longer, here how I do my ubuntu ssd tweak.
Note: this article will help both Linux SSD and mechanical hard drive performance. If you want to improve and tweak your Ubuntu, Linux Mint, Fedora, Centos or any Linux distribution, this article will help you.
- Faster than traditional HDD, about 2-3 times faster than SATA2 7200 RPM HDD
- No moving parts
- Lower heat during operating
- Uses less power
- Higher reliability
Let’s talk about SSD types for a little bit. If you are in the market and looking to purchase your first SSD, you should do a bit of research before you order your SSD. Not every SSD is created equal, there are differences in type of ssd controller, ssd memory chip, MTBF (Mean time between failures) or lifespan for short, features. Every SSD manufacture “cook” their SSD differently with different feature, but in general there are three SSD types in the market, SLC (single level cell), MLC (multi level cell), and TLC (triple level cell). There are huge differences between SLC, MLC, and TLC in term of performance and MTBF.
SLC (single level cell) has the highest performance and longer endurance over Multi-Level Cell (MLC) NAND and Triple-Level Cell (TLC). Each SLC cell can have 100.000 write/erase cycles. SLC is most often found in enterprise-grade SSDs, usually 10x more persistent, 3x faster Sequential Write same Sequential Read, and about 30% more expensive than MLC.
MLC (multi level cell) is the most popular SSDs in mid range market which is targeted at consumer-grade. Each MLC cell can have 10.000 write/erase cycles. Nowadays cameras, smartphones, USB flash drive and portable music players use MLC SSDs. Most SSDs in the market now are MLC. Being slower and has lower lifespan than SLC, MLC SSDs are usually cheaper while provide excellent performance compare to traditional mechanic hard drive.
TLC (triple level cell) has higher density than SLC and MLC, means TLC will have the lowest endurance limit and slower read and write speeds than other twos. Each TLC cell can have 5.000 write/erase cycle. Most TLC SSDs are manufactured by Samsung, has higher power and error correction requirements, and higher wear levels. TLC can be found at low-end or entry-level SSDs.
If you have the budget, SLC (single level cell) SSDs are the best choice, otherwise MLC (multi level cell) SSDs should be great for most office/home user while the price is right. There are many bad reviews about TLC (triple level cell) SSDs, usually sudden dead (stop working without any sign), while very small percentage reach their MTBF (Mean time between failures). If you can, avoid TCL SSDs.
Update your SSD firmware
SSD manufactures (Intel, Samsung, SanDisk, Plextor, Corsair, Crucial…) often public new firmwares for their SSD to improve
improve performance, reliability, and system compatibility, fix technical issues, bugs). Check your SSD’s manufacture often to make sure you have the latest firmware for your SSD. *** Always backup before you do anything ***
Use EXT4 file system
Most modern new linux distributions default file system is EXT4. EXT4 gives you good speed and reliable for your SSD, EXT4 also supports TRIM. EXT4 is matured for SSD usage since linux kernel 2.6.28. If you have older linux distributions, you may have an option to choose EXT4 as file system, but newer linux distributions will install with EXT4 as default so you don’t need to worry about.
TRIM (Trim command let an OS know which SSD blocks are not being used and can be cleared)
Back up fstab first in case something wrong happen.
# cp /etc/fstab ~/fstab.bk
Edit fstab file
# nano /etc/fstab
Add discard to your ssd drives or partitions, after ext4
UUID=bef10b86-494d-41c6-aa46-af72cfba90fd / ext4 discard,errors=remount-ro 0 1
Adding noatime and nodiratime
noatime and nodiratime are mount options in linux for linux file system. noatime disables atime updates on file system, and nodiratime will disables atime updates on directory system. By adding noatime and nodiratime will greatly reduce ssd load means performance gains.
Edit fstab file
# nano /etc/fstab
Add noatime,nodiratime to your ssd drives or partitions, after ext4
UUID=bef10b86-494d-41c6-aa46-af72cfba90fd / ext4 discard,noatime,nodiratime,errors=remount-ro 0 1
Hibernate and suspend sometimes don’t work depends on the hardware you have for your system. Sometimes they make your system crash and unstable. Plus hibernation will put a lot of writes to your SSD which will shorten your SSD life.
# nano /usr/share/polkit-1/actions/org.freedesktop.upower.policy
Change from “yes” to “no”, there are two, one for hibernation, and another one for suspend. If you have to disable them both, make sure to replace them both from yes to no.
Files and directories store in tmpfs is temporary, tmpfs keeps everything in virtual memory (kernel internal caches), nothing will be saved on your hard drive or SSD. Once your system is restarted, everything in tmpfs will be gone. Normally linux system cache stores in /tmp directory. To reduce writes on SSD, you can mount /tmp to tmpfs.
Edit fstab file
# nano /etc/fstab
Add the line to the end of fstab file
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
If logs aren’t important for you (laptop or desktop), you can also mount /var/log to tmpfs. Add the line to the end of fstab file
# SSD tweak : temporary directories as tmpfs
tmpfs /tmp tmpfs defaults,noatime,mode=1777,size=20% 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0
# SSD tweak : log directory as tmpfs
tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0
tmpfs /var/lock tmpfs defaults,noatime,mode=0755 0 0
tmpfs /dev/shm tmpfs defaults,size=20% 0 0
Preload is a Linux software developed by Behdad Esfahbod. Preload learns programs that users use often, records statics using Markov chains, analyzes, and predicts what programs will be most used. Preload then will load those programs, binaries, and dependencies into memory or ram. By having programs already in RAM or memory, it will take less time when you actually start that program or programs.
To install preload on Ubuntu, Linux Mint or debian based distributions
# apt-get update && apt-get install preload
To install preload on Fedora, Centos or Redhat based distributions
# yum install preload
Swap and Swapiness
Swappiness is a part of Linux kernel that let you control how much swap (virtual memory) file is being used. Swappiness values can be changed from 0 to 100. The higher swappiness values the more Linux kernel will try to use swap space, the lower swappiness values means linux kernel will useless or try not to use swap space depends on our setting. The default swappiness value from linux kernel is 60, if your system have plenty have RAM, you should avoid using swap space which writes and reads will be on your SSD or hard drive. For system with 4 GB or more RAM, I would suggest to reduce the usage of swap by changing swappiness settings to between 10 even 0.
To check your swappiness setting on your system, you should see the value of 60 as default.
$ cat /proc/sys/vm/swappiness
The value is up to you to decide. Here is my suggestion
- 2 GB = 30
- 4 GB = 10
- 6 GB or more = 0
To change swappiness setting:
$ su -
And add this line into sysctl.conf file.
vm.swappiness = 10
Disk Caching and virtual memory (VM) subsystem
dirty_background_ratio is the maximum percentage of dirty pages stores in total system memory before need to be written to disk when pdflush/flush/kdmflush or kernel flusher threads kick in. The default value of dirty_background_ratio depends on your linux distribution, but we are going to decrease its value to prevent heavy disk I/O.
To check default setting for dirty_background_ratio
# sysctl vm.dirty_background_ratio
vm.dirty_ratio is the percentage of total system memory to store dirty pages. Low vm.dirty_ratio means the kernel will flush dirty data to disk more often with smaller writes, and higher vm.dirty_ratio will allow kernel to flush dirty data to disk less often with bigger writes. We want to set vm.dirty_ratio high.
To check default setting for vm.dirty_ratio and vm.dirty_background_ratio
# sysctl vm.dirty_ratio
To adjust vm.dirty_ratio and dirty_background_ratio, edit sysctl.conf
# nano /etc/sysctl.conf
Add to your sysctl.conf file
Move Firefox cache to RAM
Firefox saves its cache to HDD or SSD, if you want to reduce writes to your SSD to increase SSD’s life, well move all firefox cache to RAM which will speed up firefox a little bit but all the cache will be gone after you restart your computer.
Open firefox, in the address bar type in
You will see some sort of warn, basically if you don’t know what you are doing you may break firefox. You can move on and click on “I will be careful, I promise”. In the search bar (the about:config search bar, not the regular firefox search bar), type in
If the search result is blank means your firefox does not have that string. To create one, right click on firefox empty white space, click New > String with the value name is
Click Ok, the next box is the cache location, type in
Restart firefox after you done.