SSD Writing Performance Test with Customized Partition Alignment Settings.

Submitted by yannek on Sun, 03/10/2021 - 13:42


Script is available on GitHub.



When I was replacing my old HDD with a new SSD in my Linux-based laptop I started to explore the topic which always was a concern since SSD appeared on the market. I mean a proper 'partition alignment', that does not decrease disk read/write performance. Firstly, I checked my disk vendor website but they just advised to use one of the data cloning tools in case of migration from an HDD to SSD. Fair enough, however, I was looking for more flexible method that could allow me changing partitions' layout and the file systems they were formatted with. The only thing I wanted to know was whether the Linux well-known tools like parted or fdisk were able to perform proper partition alignment for me automatically or I had to take extra care of it. I went through some articles looking for that information. Most of those articles were published within the years 2013-2014, and most of them explain how to check if the partition is aligned correctly and how to enumerate the parameters (options) of partitioning tools for correct partition alignment. Finally, I found Intel's document on this topic. Though this doc is related to Intel's SSDs, the issues are common to all SSDs based on NAND flash memory. They presented the issues related to misaligned partitioning and explained how to create a partition correctly aligned. They also included the information I was looking for. They mentioned that newer versions of Linux partitioning tools use an appropriate offset to align partition correctly. Having that said, I jumped to manual pages of two popular tools: fdisk and parted. Manual of fdisk did not contain any information about partition alignment. Opposite to that, parted's manual explained four parameters of option --align that was supposed to declare the way of partition alignment. Naturally, I started to explore parted's abilities. BTW. It is worth to emphasize one thing: it was not for the first time when I wasted some time browsing the Internet for some information about the abilities of a particular tool. Instead of that, it would be far more efficient checking tool's manual page first ( man parted  in that case) 😉


Purpose of the script.

As I mentioned above, parted offers --align option with one of four parameters: none, cylinder, minimal, or optimal. Although these parameters are well-described in parted's manual, I wanted to find out more of their practical use, especially in connection with some units available within parted, like sector, byte, and multiple-byte units based both on power of 10 and power of 2. To make the results of my tests easier for comparing and analyzing, I developed a bash script where input parameters are provided with JSON-formatted config file. This script is available on GitHub.

The other purpose for writing this script was the same as always: to keep on coding 😉

!!! Warning !!!

  • This script performs the writing tests to the tested disk drive. Thus, this script should be run for testing empty drives or the drives containing the data that is completely not important for you.
  • Take an extra care when you are using this script. You may loose your data by your mistake.


How this script works.

  1. First, it is checked if the script is being run with the root privileges. If not, script ends its work.
  2.  parted  parameters are read from JSON-formatted  config/script-params.json  file.
  3. List of SCSI/SATA block devices available in the system is displayed. A user is being prompted for selecting one of them to make a writing performance test on it.
  4. After selection is done, the  msdos  disk label  (MBR partition table) is created on a selected disk.
  5. The writing tests are being done due to the data sets provided with JSON config file. More about the data sets and JSON config file you can find below. The tests are performed with  dd  which writes 1 GiB of zeroes to a newly-created partition that begins and ends due to the data read from JSON config file.  dd  displays a result of the test - the time consumed for test completing.
  6.  parted's info about partition layout on the tested disk is displayed. A sector is used then as  parted's unit.
  7. The partition, that was created for testing purposes, is being removed.
  8. If there is another data set read from the script configuration file, the steps from 3 to 7 are repeated for this data set. Otherwise, the script finishes its work.


Script configuration file.

Script does writing performance test due to the settings read from JSON-formatted script configuration file located in  config/ subdirectory  (relative path with the filename looks like this:  config/script-params.json ). Here is the structure of this file:

    "parted": [
            "align": "none",
            "unit": "MiB",
            "start_offset": 1,
            "end_offset": 5001
            "align": "none",
            "unit": "MB",
            "start_offset": 1.05,
            "end_offset": 5001


To be continued...😉