Linux on Solid State Drives

A fast and reliable computing combination

Solid State Drives (SSDs)
are great. They have no moving parts, are shock resistant, consume less power,
produce less heat, and are orders of magnitude faster than conventional drives. A key reason for the
increased speed and durability is the lack of moving parts. With no motors or high current components, there
is less power needed to operate an SSD. Another advantage of solid state design is the vast reduction of seek
time, since there is no longer a need to precisely move a read / write head to a specific place on the drive.
These advantages make it possible for modern solid state drives to provide fantastic storage performance AND
operate for a very long time before failure. In fact, the newest SSDs will probably outlast the computers
in which they are installed.

There are two issues of greater concern for SSD users: write amplification and overall longevity. Write
amplification is a term describing the fact that writing a small block of data to an SSD may involve copying
and rewriting a much larger block on the drive, at the expense of time and write events. Longevity relates to
the fact that there is a limit to the number of times that data can be written to a solid state drive.
Therefore, it is in the user's interest to eliminate all writes that are not necessary, and use RAM as much as
possible for things such as log files, temporary data, web cache, etc. Respecting these limits can extend the
life of an SSD well beyond the life expectancy of other computer components.

A conventional hard drivewith spinning disks.

SSD speeds are considerably faster than conventional drives.

A solid state drive with fast seek times and no moving parts!

Linux can work quite well on solid state drives. However, the system's default behavior is optimized for
conventional hard drives. After some minor edits to files controlling system behavior, a Linux system can make
very efficient use of its resources and perform orders of magnitude faster than with legacy "spinning disk"
storage. System adjustments given here focus on these changes:

Reducing the number of file attribute writes to the SSD

Improving the input - output scheduling

Moving temporary and log files into RAM

Moving the Firefox cache into RAM

FSTAB EDITS TO REDUCE SSD WRITES

The first system adjustment is to mount volumes using the noatime option. By default Linux will write
the "time last accessed" attribute to files. This can reduce the life of your SSD by causing a lot of writes.
Using the noatime mount option turns this off.

The next adjustment will implement the use of a ramdisk instead of the SSD to store temporary files. These
temporary files are written and rewritten frequently, and are best kept in RAM and off the solid state drive.
This also increases overall system speed, especially on more modern systems equipped with ample memory.

Open your fstab file for editing, using one of the following command lines (depending on what you prefer to
use):

~$ sudo gedit /etc/fstab

OR...

~$ sudo nano /etc/fstab

OR...

~$ sudo kwrite /etc/fstab

Look at the line specifying partitions on the SSD. It will look similar to this:

UUID=1eea26d7-6893-4779-827b-150412c94703 / ext2 relatime 0 1

Replace "relatime" with "noatime" to stop the system from writing the last access times as discussed above.
Next, add the following lines to fstab to put temporary and log files in RAM instead of on the solid state
drive:

SSD OPTIMIZED INPUT - OUTPUT SCHEDULING

An I/O scheduler decides the order in which applications are given access to the SSD for writes and reads.
In Linux, the default I/O scheduler in Linux is called CFQ, Completely Fair Queuing. CFQ generally works
well, but it is not perfect for SSDs. Its default behavior is to give drive access on a first come - first
serve basis. Sometimes overall system performance can be enhanced by using a different scheduling order.
Also, there are schedulers which cause less wear on solid state drives. Two of the better I/O schedulers for
SSDs are noop and deadline, and they are faster than CFQ when an application is writing large files.

To see the current scheduler in use for a disk on your system (and alternative I/O schedulers), use the
"cat" command to view the scheduler file. The active scheduler will be in brackets:

To change the I/O scheduler of a disk to deadline (temporarily - until shutdown or reboot), use the "echo"
command to write "deadline" into the scheduler file. Sudo is needed for root priveleges. In this example,
drive sda will be set to use "deadline" with the option "fifo_batch":

Note: disk sda is shown; substitute sdb, hda, or whatever device for which you want to change scheduling.

A drive's I/O default scheduler can be set automatically at boot time by entering the proper option into
the boot loader. For example, a system using GRUB2 or GRUB-PC would need the option set inside the file
/etc/grub.d/10_linux (look near line 80):

MOVE FIREFOX’S CACHE TO RAM

One of the things that makes Firefox such a fantastic web browser is its flexibility. It can be configured
to do so many things, and do them well. Moving the cache into RAM enhances the browser's speed and reduces
writes to the SSD. Be aware that each user on the computer has their own Firefox configuration.
Repeat the following steps for all user accounts on the system.

Open Firefox, type about:config in the address bar, and press Enter. Promise to be careful! In an empty
space on the screen, right-click and create a new String:

value browser.cache.disk.parent_directory

Set the new string value to:

/tmp

The above system tweaks will optimize your Linux computer for usage of
solid state drive storage. As the
Linux kernel develops, many of these enhancements will be incorporated and we will see SSD optimized system
behavior as the default. Stay tuned, and enjoy lightning fast computing with solid state drives!

Back up your data regularly, regardless of the storage medium used! Any device can have the bad
luck to fail just after you save your most precious data...