Optimize flash memory in Linux
Fine-tuned
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.
Alignment
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 05 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
Over-Provisioning
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.
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
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.