SSD – Linux Hint https://linuxhint.com Exploring and Master Linux Ecosystem Sun, 07 Feb 2021 02:13:26 +0000 en-US hourly 1 https://wordpress.org/?v=5.6.2 Two Powerful SSD Benchmark Utilities for Linux https://linuxhint.com/two-powerful-ssd-benchmark-utilities-linux/ Sat, 23 Jan 2021 16:49:25 +0000 https://linuxhint.com/?p=87213 The 21st century has seen unprecedented growth in the technological sector, and many upgrades have been made in the past several years. The evolution of phones from landlines to smartphones is a clear indicator of this technological phenomenon. The latter has become a key part of our lives, providing us a means to connect with the world around us. The desktops and laptops that we use today have also seen major progression, and this can be observed in the improvement in the quality of tools and games in the world of computers.

One such sector in the computer world is that of memory storage, which has quickly moved on from traditional hard disks to a newer, faster type of storage called a solid-state drive, or SSD for short. SSDs are extremely fast, require less power, and are more shock-resistant than HDDs. You can see this for yourself by benchmarking your SSDs. Benchmarking is the process of measuring the performance of any tool, which can be done using a benchmarking utility.

This article looks at two of the best utilities available for SSD benchmarking in the Linux operating system, Disks and hdparm.

Tools to Use for Benchmarking SSDs

Linux offers a wide collection of tools to its users, each of which is catered to meet the interests of different user types. From among the large collection available, users can easily choose the tool with which they are most comfortable. The same is the case with SSD benchmark utilities. There are several excellent benchmark utilities available for Linux, including KDiskMark, sysbench, sysstat, Phoronix Test Suite, and more.

In this tutorial, we will look at two tools, both of which come preinstalled in most Linux systems. One of the utilities will be a GUI-based tool, and the other utility will be a command-line-based tool.

For users who prefer using the GUI, Disks is the best option. Disks is a powerful GUI disk management tool that comes preinstalled in almost every Linux system. This utility has an extremely easy-to-use interface, and you can easily check your benchmark results using this tool. The other tool that we will look at is hdparm, a simple command-line application that includes the option to check out the performance of storage devices.

Benchmarking SSDs Using Disks

As mentioned before, Disks comes preinstalled in almost every Linux system. However, if this tool is not present in your system, run the following command in the terminal to install Disks:

$ sudo apt-get install -y gnome-disk-utility

To open Disks, search for the application in the search bar, and an application with the name Disks and a CD icon will appear in the results list.

Click the icon to open the Disks application. The window that opens will contain all storage devices present in your system. Scroll down to find the SSD device that you would like to benchmark.

Next, click the gear icon below the Volumes section, then select Benchmark Partition from the choices available in the drop-down menu.

Selecting the Benchmark Partition option will open a window in which various details regarding your SSD will be present, such as the last time that it was benchmarked, the sample size selected for the benchmark process, and the average read, write, and access rates. If this is your first time benchmarking the SSD, then everything else, apart from the name of your Disk, will appear blank.

To start the Benchmark process, click the Start Benchmark button found in the bottom-left corner of the window.

After clicking this button, a new window will open. In this window, there will be various options, such as the Transfer Rate and the Access Time. For the Transfer Rate, you must specify the number of samples you want for the benchmark process and define the total size of these samples. There is also a Perform write-benchmark option present, which you should disable if you do not want your data in the SSD to get overwritten. Note that if you do go for a write benchmark, be sure to backup all your data, as it will be erased in the overwrite.

Finally, once you are finished setting up everything, click the Start Benchmarking button, and the benchmarking process will start. During the benchmarking process, the average reading, writing, and access times will continue updating. Once the process is complete, your results will appear.

An HDD will have results similar to the following:

As you can see in the results above, SSDs are nearly ten times faster in both reading and accessing the data.

Benchmarking SSDs Using hdparm

Hdparm is a command-line performance-testing tool that comes preinstalled in almost every Linux system. If hdparm is not present in your system, run the following command in the terminal to install hdparm:

$ sudo apt install hdparm

To benchmark your SSD using hdparm, open your terminal and issue the following command:

$ sudo hdparm -tT DeviceName

DeviceName refers to the name of your SSD. You can easily verify this output by running the following command:

$ lsblk -d -o name,rota

Here, the output one refers to a hard disk, while the output zero refers to an SSD. The result we get from this is as follows:

Meanwhile, the result we get from an HDD is:

As you can see from the results, SSDs are once again much faster than hard drives.

So, Why Should You Benchmark Your SSD?

Benchmarks are an excellent way to test the performance of your storage devices and also other computer parts. These utilities also allow users to compare their results with others, and check whether improvements are needed.

]]>
What is SSD TRIM? https://linuxhint.com/ssd_trim/ Wed, 24 Apr 2019 06:43:58 +0000 https://linuxhint.com/?p=39285 SSDs are a completely different storage media compared to the ones that existed before it. Magnetic media, especially spinning disks, have introduced a lot of concepts like sector size, partitioning, fragmentation etc. Some of these ideas have been emulated in the firmware Solid state devices as well.

On the flip side, new concepts have been introduced in order to optimize the performance, life span and reliability of these novel devices as well. One such concept is the TRIM operation.

Layout of an SSD

SSDs are blazingly fast and are getting faster and cheaper every year. Their reliability also has improved quite a bit since their inception. However, SSDs are still not as reliable as magnetic media, neither are they as durable as a hard disk. In fact, the underlying read-write mechanisms are very different from what one sees inside an HDD.

To understand the problems an SSD suffers from, and why we need TRIM operation to overcome those problems, let’s look at the structure of the SSD first. Data is stored typically in groups of 4KB cells, called pages. The pages are then grouped into clusters of 128 pages, called Blocks and each block is 512KB, for most SSDs.

You can read data from a page that contains some information or you can write data to pages that are clean (with no preexisting data in them, just a series of 1s). However, you can’t overwrite data on a 4KB page that has already been written to, without overwriting all the other 512KB.

This is a consequence of the fact that the voltages required to flip a 0 to 1 are often much higher than the reverse. The excess voltage can potentially flip bits on the adjacent cells and corrupt data.

Deletion Operation the Performance Degradation of an SSD

When data is said to be ‘deleted’ by the OS, the SSD merely marks all the corresponding pages as invalid, rather than deleting the data. This is quite similar to what happens inside an HDD as well, the sectors are marked as free rather than getting physically zeroed out. This makes the deletion operation much much faster.

In case of HDDs, this works just fine. When new data needs to be written, you can overwrite the old data on a freed sector without any issues or worries about the surrounding sectors. HDDs can modify data in-place.

In the case of an SSD, this is not so simple. Let’s say that you modify a file and that corresponds to a change of a single 4KB page. When you try to modify a 4KB page in an SSD, the entire content of its block, the whole 512KB of it, needs to read into a cache (the cache can be built into the SSD or it can be the system’s main memory) and then the block needs to be erased and then you can write the new data your target 4KB page. You will also have to write back the remaining unmodified 508KB of data that you copied to your cache.

This results adds to the phenomenon of Write Amplification where each write operation gets amplified to a read-modify-write operation for chunks of data that are much larger than the actual data that needs to be put in place.

Initially, this amplification doesn’t show up. Your SSD performs very well in the beginning. Eventually, as blocks get filled up, the inevitable point is reached where more and more write operations start involving the expensive read-modify-write operations. The user starts noticing that the SSD is not performing as well as it initially did.

SSD controllers also try to make sure that the data is spread out throughout the disk. So that all dies get equal levels of wear. This is important because flash memory cells tend to wear-out quickly, and therefore if we continuously use only the first few thousands of blocks ignoring the rest of the SSD, those few blocks will get worn out soon. Spreading data across multiple dies also improves your performance as you can read or write data in parallel.

However, now the writes are spread out, increasing the chances of a block having a page. This further accelerates the degradation process.

TRIM Command and Freeing of the Blocks

The TRIM command minimizes performance degradation by periodically trimming the invalid pages. For example, Windows 10 TRIMs your SSD once every week. All the data that has been marked as deleted by the OS gets actually cleaned out of the memory cells by the SSD controller when that operation is run. Yes, it still has to go through the read-modify-write operation but it happens only once a week and can be scheduled in the hours when your system is mostly ideal.

The next time you want to write to a page, it is actually empty and ready for a direct write operation!

The actual frequency of TRIM command depends on the kind of system you are running. Databases tend to do a lot of IOs and would thus require a more frequent trimming. However, if you do it too frequently the database operations will slow down for the period when TRIM is running. It is the job of a system architect to find the right schedule and frequency.

Limitations

TRIM command is very useful in delaying the performance degradation of your device. It helps maintain the average performance of your device. But that’s only on average.

Suppose, if you are working with a text document and are constantly write to the file, editing things out and saving so you don’t lose any progress. The pages storing the document’s data will still need to go through the excruciating read-modify-write cycle because TRIM is not a service that’s constantly optimizing your SSD. Even if it did run as a service, the performance impact will still be visible because it is built into the very mechanics of an SSD’s operation.

Also running SSD TRIM too often can reduce the longevity of your storage. Since all that deletion and write-cycle will wear out the cells rendering the data stored within them read-only.

Conclusion

Despite all the shortcomings of an SSD it still packs massive performance benefits when compared against a traditional hard disk drive. As the market share for these magical devices grows, more research and engineering efforts will be directed towards bettering the underlying technology.

Operating system vendors, SSD chip manufactures and the people who write all the complex firmware logic come together to give us this awesome device. TRIM is but one of the many many layers of complexity that’s packed in there.

References

  1. AnandTech and their wonder research and review of SSDs.
  2. Wikipedia article on Write Amplification
  3. Write up on Arstechnia about SSDs and their internal workings
]]>