Optimize flash memory in Linux


Article from Issue 187/2016

Solid state drives make everything run faster and more smoothly, but you can squeeze out even more performance with some practical optimization steps.

Solid-State drives (SSDs) are quite different from old-fashioned hard disks, and you'll have to learn some new techniques if you want to tune up performance. This article highlights some important steps for optimizing SSDs.

Updating the Firmware

Firmware is just as important as hardware, and the flash chips in the SSD are no exception. Special software mechanisms such as wear leveling and garbage collection improve the efficiency of the drive; without these mechanisms, the durability and performance of the SSD would be impaired over its service life. The firmware is thus an important part of the product, and it is also under constant development, which means it is important to update the firmware.

Linux users are often a little envious when they see how easy it is to install new firmware in Windows by clicking around in a graphical interface. Intel and Samsung provide Linux binaries for their datacenter SSDs, but for their consumer products, users need to boot an ISO file.


When SSDs first started to become more widespread, correct alignment [1] had not yet been implemented in the popular partitioning tools. Today, command-line utilities such as fdisk, gdisk, or parted pay attention to correct alignment of the partitions, making sure, for example, that the first partition starts in sector 2048. The example in Listing 1 demonstrates how to correctly create a new partition and test it with align-check.

Listing 1

Creating a Correctly Aligned Partition

01 $ sudo parted /dev/sdb mklabel gpt
02 $ sudo parted -a optimal -- /dev/sdb mkpart primary 0% 100%
03 $ sudo parted /dev/sdb align-check opt 1
04 1 aligned
06 $ sudo gdisk -l /dev/sdb
07 [...]
08 Number Start (sector) End (sector) Size Code Name
09  1 2048 390721535 186.3 GiB 8300 primary


All SSDs have a spare area, that is, a reserved data area that is not directly visible to the operating system, which the SSD uses internally for the wear leveling and bad-block replacement, as well as read, modify, and write operations.

Especially with low-budget consumer SSDs without a trim function, increasing the size of the spare area (aka over-provisioning) is a good way to improve durability and performance. However, enterprise SSDs already come with a higher gross capacity and tolerate more writes, that is, they show a larger value for Terabytes Written (TBW). The DC S3500 SSD shown in Figure 1 has 336GB flash chips for a nominal capacity of 300GB. The graph shows how the write performance improves for the 800GB model given a bigger spare area.

Figure 1: 20 percent over-provisioning boosts the write IOPS for an Intel DC S3500 with 800GB capacity from approximately 12,000 to approximately 33,000 IOPS, and this improves to over 47,000 IOPS for 40 percent over-provisioning. The performance remains unchanged for read only access.

It is best to set up over-provisioning before an SSD goes into production operation. You have several configuration options: the first method is to set up a host-protected area (HPA) with hdparm. To create an HPA, you'll need to delete all the blocks on the SSD. (You'll need to delete the blocks so the SSD controller will be able to actually use the hidden data areas for wear leveling later on.) The blocks are deleted for an SSD in an as-delivered state. However, if the device has already been used, you need to restore this state with a secure erase or manual trim (depending on the SSD). Typing the following:

hdparm -Np number_of_sectors /dev/sdb

sets up the host-protected area.

With the second method, you just leave an area on the SSD unpartitioned and create partitions for, say, only 90 percent of the disk's capacity. In this case as well, you need to perform a secure erase up front if the SSD was previously in use. The operation deletes and frees up all the flash cells.

The third method is to use the vendor's SSD tools, such as Intel's isdct or Samsung's magician.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Tuning Your SSD

    Nothing accelerates a PC like transitioning to an SSD, but some special configuration might be in order if you want to get the most from your drive.

  • hdparm Drive Utility

    Hdparm is the tool to use when it comes to tuning your hard disk or DVD drive, but it can also measure read speed, deliver valuable information about the device, change important drive settings, and even erase SSDs securely.

  • Performance Tweaks

    If you are looking for ways to speed up your Linux, consider this collection of curated performance tweaks.

  • PCIe SSDs

    A PCIe SSD can accelerate your system considerably, but you need to do your homework and choose the right product for your computer.

  • Migrating to an SSD

    Replacing your hard drive with an SSD is a sure way to speed up your system; however, migrating to an SSD is a little more complicated than you might imagine. We'll help you find your way through the pitfalls.

comments powered by Disqus