{"id":18851,"date":"2023-10-13T13:15:09","date_gmt":"2023-10-13T13:15:09","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=18851"},"modified":"2023-10-13T13:49:38","modified_gmt":"2023-10-13T13:49:38","slug":"use-hdparm-measure-speed-data-reads-writes-linux","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/use-hdparm-measure-speed-data-reads-writes-linux\/","title":{"rendered":"How to Use \u2018hdparm\u2019 to Measure the Speed of Data Reads\/Writes on Storage Devices in Linux"},"content":{"rendered":"<p><img decoding=\"async\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests-1024x768.jpg\" alt=\"How to Use HDPARM Utility for Storage I_O Performance Tests\" width=\"1024\" height=\"768\" class=\"alignnone size-large wp-image-18853 lazyload\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests-1024x768.jpg 1024w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests-300x225.jpg 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests-128x96.jpg 128w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests-420x315.jpg 420w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests-540x405.jpg 540w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests-720x540.jpg 720w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests-960x720.jpg 960w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests-1140x855.jpg 1140w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests-1320x990.jpg 1320w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-HDPARM-Utility-for-Storage-I_O-Performance-Tests.jpg 1400w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/p>\n<p>In Linux, hdparm is a powerful command-line tool that provides a plethora of functionalities for hard disk drives, including the ability to measure the speed of data reads\/writes. This is crucial for webmasters and system administrators who wish to gauge the performance of their storage devices.<\/p>\n<p>Whether you&#8217;re running a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-are-web-servers-and-why-are-they-needed\/\">web server<\/a>, or simply want to optimize your personal computer, understanding your storage I\/O performance can make a significant difference.<\/p>\n<p>In this tutorial I will show how to use hdparm to measure storage I\/O performance on a Linux machine.<\/p>\n<p>Before diving into the tutorial, it&#8217;s essential to have a basic understanding of different web servers like <a href=\"https:\/\/webhostinggeeks.com\/blog\/apache-http-server-explained\/\">Apache<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/nginx-server-explained\/\">Nginx<\/a>, and <a href=\"https:\/\/webhostinggeeks.com\/blog\/litespeed-web-server-explained\/\">LiteSpeed<\/a>. Additionally, knowledge about various hosting types such as <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-dedicated-server-hosting\/\">dedicated server<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-vps-hosting\/\">VPS server<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-cloud-hosting\/\">cloud hosting<\/a>, and <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-shared-hosting\/\">shared hosting<\/a> can be beneficial.<\/p>\n<p>Let&#8217;s get started.<\/p>\n<h2>Step 1: Installing hdparm<\/h2>\n<p>Before you can use hdparm, you need to ensure it&#8217;s installed on your system:<\/p>\n<pre>\r\nsudo apt-get update\r\nsudo apt-get install hdparm\r\n<\/pre>\n<h2>Step 2: Identifying the Storage Device<\/h2>\n<p>To measure the speed of a specific storage device, you first need to identify it. Use the following command:<\/p>\n<pre>\r\nlsblk\r\n<\/pre>\n<p>This command will list all the storage devices on your system. Note the device name you wish to test, e.g., <strong>\/dev\/sda<\/strong> or <strong>\/dev\/vda<\/strong>.<\/p>\n<p>For example:<\/p>\n<pre>\r\nroot@geeks:~# lsblk\r\nNAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT\r\nsr0      11:0    1   368K  0 rom\r\nvda     252:0    0   220G  0 disk\r\n\u251c\u2500vda1  252:1    0 219.9G  0 part \/\r\n\u251c\u2500vda14 252:14   0     4M  0 part\r\n\u2514\u2500vda15 252:15   0   106M  0 part \/boot\/efi\r\nroot@geeks:~#                            \r\n<\/pre>\n<h2>Step 3: Testing Data Read Speed<\/h2>\n<p>To measure the read speed of your storage device, use the following command:<\/p>\n<pre>\r\nsudo hdparm -t \/dev\/sda\r\n<\/pre>\n<p>For example:<\/p>\n<pre>\r\nroot@geeks:~# sudo hdparm -t \/dev\/vda\r\n\r\n\/dev\/vda:\r\n Timing buffered disk reads: 1230 MB in  3.00 seconds = 409.94 MB\/sec\r\nroot@geeks:~#  \r\n<\/pre>\n<p>Replace \/dev\/vda with the name of your device. This command will provide the speed of data reads in MB\/s.<\/p>\n<h2>Step 4: Testing Cache Read Speed<\/h2>\n<p>To measure the speed of reads from the drive&#8217;s cache buffer, use:<\/p>\n<pre>\r\nsudo hdparm -T \/dev\/sda\r\n<\/pre>\n<p>For example:<\/p>\n<pre>\r\nroot@geeks:~# sudo hdparm -T \/dev\/vda\r\n\r\n\/dev\/vda:\r\n Timing cached reads:   19436 MB in  2.00 seconds = 9730.59 MB\/sec\r\nroot@geeks:~#  \r\n<\/pre>\n<p>Again, replace \/dev\/vda with your device name. This command gives an idea of how fast the drive can transfer data from its built-in cache.<\/p>\n<h2>Step 5: Combining Both Tests<\/h2>\n<p>You can combine both tests to get a comprehensive view of your drive&#8217;s performance:<\/p>\n<pre>\r\nsudo hdparm -Tt \/dev\/sda\r\n<\/pre>\n<p>For example:<\/p>\n<pre>\r\nroot@geeks:~# sudo hdparm -Tt \/dev\/vda\r\n\r\n\/dev\/vda:\r\n Timing cached reads:   21486 MB in  2.00 seconds = 10758.31 MB\/sec\r\n Timing buffered disk reads: 1450 MB in  3.00 seconds = 482.69 MB\/sec\r\nroot@geeks:~#   \r\n<\/pre>\n<h2>Additional Useful Tests with hdparm<\/h2>\n<p>Beyond the basic read\/write speed tests, hdparm offers a range of functionalities that can help you understand more about your storage device&#8217;s performance and characteristics. Here are some additional tests and commands you can use with hdparm:<\/p>\n<h3>1. Displaying Drive Information<\/h3>\n<p>To get detailed information about your drive, including its model number, serial number, and supported features:<\/p>\n<pre>\r\nsudo hdparm -I \/dev\/sda\r\n<\/pre>\n<h3>2. Checking for Advanced Power Management<\/h3>\n<p>Advanced Power Management (APM) can influence the performance and power usage of your drive. To check the APM level:<\/p>\n<pre>\r\nsudo hdparm -B \/dev\/sda\r\n<\/pre>\n<h3>3. Setting Advanced Power Management Level<\/h3>\n<p>If you want to set the APM level (values can range from 1-255, with 1 being the most aggressive power saving mode):<\/p>\n<pre>\r\nsudo hdparm -B 127 \/dev\/sda\r\n<\/pre>\n<h3>4. Checking Drive&#8217;s Power Mode<\/h3>\n<p>To determine if your drive is active, in standby, or sleeping:<\/p>\n<pre>\r\nsudo hdparm -C \/dev\/sda\r\n<\/pre>\n<h3>5. Setting Drive to Standby Mode<\/h3>\n<p>If you wish to manually set your drive to standby mode:<\/p>\n<pre>\r\nsudo hdparm -y \/dev\/sda\r\n<\/pre>\n<h3>6. Secure Erase<\/h3>\n<p>For those looking to securely erase data from a drive (use with caution as this will remove all data):<\/p>\n<pre>\r\nsudo hdparm --security-erase NULL \/dev\/sda\r\n<\/pre>\n<h3>7. Displaying Acoustic Management Settings<\/h3>\n<p>To check the current acoustic management settings of the drive:<\/p>\n<pre>\r\nsudo hdparm -M \/dev\/sda\r\n<\/pre>\n<h2>Commands Mentioned<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo apt-get update<\/span> \u2013 Updates the package lists for upgrades and new packages.<\/li>\n<li><span class=\"fw-bold\">sudo apt-get install hdparm<\/span> \u2013 Installs the hdparm tool.<\/li>\n<li><span class=\"fw-bold\">lsblk<\/span> \u2013 Lists all storage devices on the system.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -t \/dev\/vda<\/span> \u2013 Measures the read speed of a storage device.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -T \/dev\/vda<\/span> \u2013 Measures the cache read speed of a storage device.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -Tt \/dev\/vda<\/span> \u2013 Combines both the above tests.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -I \/dev\/sda<\/span> \u2013 Displays detailed information about the drive.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -B \/dev\/sda<\/span> \u2013 Checks the APM level of the drive.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -B 127 \/dev\/sda<\/span> \u2013 Sets the APM level of the drive.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -C \/dev\/sda<\/span> \u2013 Checks the drive&#8217;s power mode.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -y \/dev\/sda<\/span> \u2013 Sets the drive to standby mode.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm &#8211;security-erase NULL \/dev\/sda<\/span> \u2013 Securely erases data from the drive.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -M \/dev\/sda<\/span> \u2013 Displays the drive&#8217;s acoustic management settings.<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -M 128 \/dev\/sda<\/span> \u2013 Sets the acoustic management level of the drive.<\/li>\n<\/ul>\n<h2>FAQ<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the primary purpose of hdparm?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Hdparm is a command-line utility in Linux used to set and view hardware parameters of hard disk drives. It can also be used to measure the speed of data reads\/writes, among other functionalities.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">How accurate is hdparm in measuring storage performance?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Hdparm provides a basic measure of storage performance, especially for sequential data reads. However, for a comprehensive performance analysis, it&#8217;s advisable to use specialized benchmarking tools alongside hdparm.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Can hdparm be used on SSDs?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Yes, hdparm can be used on SSDs. However, due to the different nature of SSDs compared to traditional HDDs, some parameters and results might vary.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Is it safe to run hdparm on a mounted drive?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">While measuring performance using hdparm is generally safe on a mounted drive, certain operations, especially those that modify drive settings, should be done with caution on mounted drives.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">How often should I test my storage device&#8217;s performance?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Regularly testing storage device performance can help in early detection of potential issues. However, frequent tests are not necessary unless you suspect a problem or have made changes to your system that might affect performance.<\/span>\n            <\/p>\n<\/li>\n<\/ol>\n<h2>Conclusion<\/h2>\n<p>Understanding the performance of your storage devices is crucial, especially for those managing high-traffic websites or critical applications. The hdparm tool offers a straightforward way to gauge the speed of data reads\/writes on Linux systems. By following the steps outlined in this tutorial, you can effectively measure the storage I\/O performance of your hard drives or SSDs.<\/p>\n<p>While hdparm provides a basic overview of your storage device&#8217;s performance, it&#8217;s essential to remember that real-world performance can vary based on numerous factors, including system load, other running processes, and the nature of the data being accessed. Therefore, for a more comprehensive analysis, consider using a combination of tools and benchmarking methods.<\/p>\n<p>hdparm is a versatile tool that provides a plethora of functionalities beyond just measuring read\/write speeds. By leveraging its capabilities, you can gain deeper insights into your storage device&#8217;s performance, power management, and other essential characteristics. Always remember to use caution when altering drive settings and ensure you have backups of critical data before performing operations like secure erase. With the right knowledge and approach, hdparm can be an invaluable asset in optimizing and managing your storage devices on a Linux system.<\/p>\n<p>Regularly test, monitor, and take proactive steps to ensure your storage devices are in top shape, guaranteeing the smooth operation of your systems and applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux, hdparm is a powerful command-line tool that provides a plethora of functionalities for hard disk drives, including the ability to measure the speed of data reads\/writes. This is&#8230;<\/p>\n","protected":false},"author":6,"featured_media":18853,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2152],"tags":[2086,2153],"class_list":["post-18851","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-benchmarking","tag-hdparm","tag-test"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/18851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=18851"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/18851\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/18853"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=18851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=18851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=18851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}