{"id":4110,"date":"2012-10-16T23:29:46","date_gmt":"2012-10-16T15:29:46","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=4110"},"modified":"2023-06-22T16:34:48","modified_gmt":"2023-06-22T16:34:48","slug":"how-to-check-disk-read-write-speed-in-linux","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-check-disk-read-write-speed-in-linux\/","title":{"rendered":"How to Check Disk Read and Write Speed in Linux with HDPARM Utility"},"content":{"rendered":"<p>Checking the disk read and write speed is essential to understand the performance of your system and useful to determine the performance of your storage device, especially when it comes to disk read\/write speeds. This is crucial for tasks such as server management, where the speed of data transfer can significantly impact performance.<\/p>\n<p>Whether you&#8217;re using a <a href=\"https:\/\/webhostinggeeks.com\/best\/web-server\/\">dedicated server<\/a>, a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-vps-hosting\/\">VPS server<\/a>, or <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-cloud-hosting\/\">cloud hosting<\/a>, knowing how to check disk read\/write speed in Linux is a valuable skill. In Linux, there are various tools available to check disk read and write speed. <\/p>\n<p>In this tutorial, we will be focusing on how to use hdparm, a command-line utility that serves as a powerful tool for checking disk read\/write speed in Linux.<\/p>\n<p>hdparm is a Linux utility used to set and view hardware parameters of hard disk drives. It can also perform several types of disk performance measurements, such as reading disk sectors into the operating system&#8217;s page cache and measuring the speed of reading through the cache to the processor.<\/p>\n<p>I will explain how to check disk read and write speed using the hdparm and dd commands. This guide will be useful for those who want to <em>test disk speed in Linux<\/em>, specifically <em>check disk read\/write speed<\/em>.<\/p>\n<h2>Step 1: Install hdparm<\/h2>\n<p>Before we can use hdparm, we need to ensure it&#8217;s installed on our system. On most Linux distributions, hdparm comes pre-installed. However, if it&#8217;s not, you can install it using the package manager of your Linux distribution.<\/p>\n<p>For Debian-based systems like Ubuntu, use the following command:<\/p>\n<pre>\r\nsudo apt-get install hdparm\r\n<\/pre>\n<p>For Red Hat-based systems like CentOS, use the following command:<\/p>\n<pre>\r\nsudo yum install hdparm\r\n<\/pre>\n<p>For example:<\/p>\n<pre>\r\n[root@server ~]# yum install hdparm -y\r\nLoaded plugins: fastestmirror\r\nLoading mirror speeds from cached hostfile\r\n * Webmin: download.webmin.com\r\n * base: mirror.upsi.edu.my\r\n * epel: ftp.cuhk.edu.hk\r\n * extras: mirror.upsi.edu.my\r\n * updates: centos.mirror.secureax.com\r\nSetting up Install Process\r\nResolving Dependencies\r\n--> Running transaction check\r\n---> Package hdparm.x86_64 0:9.43-4.el6 will be installed\r\n--> Finished Dependency Resolution\r\n\r\nDependencies Resolved\r\n\r\n====================================================================================================\r\n Package               Arch                  Version                      Repository           Size\r\n====================================================================================================\r\nInstalling:\r\n hdparm                x86_64                9.43-4.el6                   base                 81 k\r\n\r\nTransaction Summary\r\n====================================================================================================\r\nInstall       1 Package(s)\r\n\r\nTotal download size: 81 k\r\nInstalled size: 150 k\r\nDownloading Packages:\r\nhdparm-9.43-4.el6.x86_64.rpm                                                 |  81 kB     00:00\r\nRunning rpm_check_debug\r\nRunning Transaction Test\r\nTransaction Test Succeeded\r\nRunning Transaction\r\n  Installing : hdparm-9.43-4.el6.x86_64                                                         1\/1\r\n  Verifying  : hdparm-9.43-4.el6.x86_64                                                         1\/1\r\n\r\nInstalled:\r\n  hdparm.x86_64 0:9.43-4.el6\r\n\r\nComplete!\r\n<\/pre>\n<h2>Step 2: Check Disk Read Speed<\/h2>\n<p>To check the disk read speed using hdparm, run the following command:<\/p>\n<pre>sudo hdparm -t \/dev\/sda<\/pre>\n<p>Replace \/dev\/sda with the actual device name of your storage device. This command will test the sequential read speed of your storage device and display the result in megabytes per second (MB\/s).<\/p>\n<pre>\r\n[root@centos63 ~]# hdparm -tT \/dev\/sda\r\n\r\n\/dev\/sda:\r\n Timing cached reads:   4128 MB in  2.00 seconds = 2065.62 MB\/sec\r\n Timing buffered disk reads:  276 MB in  3.06 seconds =  90.30 MB\/sec\r\n<\/pre>\n<pre>\r\n[root@centos63 ~]# hdparm -tT \/dev\/sdb\r\n\r\n\/dev\/sdb:\r\n Timing cached reads:   3410 MB in  2.00 seconds = 1705.84 MB\/sec\r\n Timing buffered disk reads:  364 MB in  3.00 seconds = 121.29 MB\/sec\r\n<\/pre>\n<h2>Step 3: Check Disk Write Speed<\/h2>\n<p>To check the disk write speed, we will use the dd command. Run the following command:<\/p>\n<pre>sudo dd if=\/dev\/zero of=test bs=1G count=1 oflag=direct<\/pre>\n<p>This command will create a test file named test with a size of 1 gigabyte (GB) and write it to your storage device. The oflag=direct option tells dd to bypass the file system cache and write directly to the disk. The bs option specifies the block size.<\/p>\n<p>After the test file is created, dd will display the write speed in bytes per second (B\/s).<\/p>\n<h2>Step 4: Clean Up<\/h2>\n<p>After you have finished testing the disk read and write speed, you can delete the test file by running the following command:<\/p>\n<pre>sudo rm test<\/pre>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo apt-get install hdparm<\/span> &#8211; Install hdparm<\/li>\n<li><span class=\"fw-bold\">sudo hdparm -t \/dev\/sda<\/span> &#8211; Check disk read speed<\/li>\n<li><span class=\"fw-bold\">sudo dd if=\/dev\/zero of=test bs=1G count=1 oflag=direct<\/span> &#8211; Check disk write speed<\/li>\n<li><span class=\"fw-bold\">sudo rm test<\/span> &#8211; Clean up<\/li>\n<\/ul>\n<h2>hdparm Usage Options<\/h2>\n<pre>\r\n[root@centos63 ~]# hdparm\r\n\r\nhdparm - get\/set hard disk parameters - version v9.16\r\n\r\nUsage:  hdparm  [options] [device] ..\r\n\r\nOptions:\r\n -a   get\/set fs readahead\r\n -A   get\/set the drive look-ahead flag (0\/1)\r\n -b   get\/set bus state (0 == off, 1 == on, 2 == tristate)\r\n -B   set Advanced Power Management setting (1-255)\r\n -c   get\/set IDE 32-bit IO setting\r\n -C   check drive power mode status\r\n -d   get\/set using_dma flag\r\n -D   enable\/disable drive defect management\r\n -E   set cd\/dvd drive speed\r\n -f   flush buffer cache for device on exit\r\n -F   flush drive write cache\r\n -g   display drive geometry\r\n -h   display terse usage information\r\n -H   read temperature from drive (Hitachi only)\r\n -i   display drive identification\r\n -I   detailed\/current information directly from drive\r\n -k   get\/set keep_settings_over_reset flag (0\/1)\r\n -K   set drive keep_features_over_reset flag (0\/1)\r\n -L   set drive doorlock (0\/1) (removable harddisks only)\r\n -M   get\/set acoustic management (0-254, 128: quiet, 254: fast)\r\n -m   get\/set multiple sector count\r\n -N   get\/set max visible number of sectors (HPA) (VERY DANGEROUS)\r\n -n   get\/set ignore-write-errors flag (0\/1)\r\n -p   set PIO mode on IDE interface chipset (0,1,2,3,4,...)\r\n -P   set drive prefetch count\r\n -q   change next setting quietly\r\n -Q   get\/set DMA queue_depth (if supported)\r\n -r   get\/set device  readonly flag (DANGEROUS to set)\r\n -R   obsolete\r\n -s   set power-up in standby flag (0\/1) (DANGEROUS)\r\n -S   set standby (spindown) timeout\r\n -t   perform device read timings\r\n -T   perform cache read timings\r\n -u   get\/set unmaskirq flag (0\/1)\r\n -U   obsolete\r\n -v   defaults; same as -acdgkmur for IDE drives\r\n -V   display program version and exit immediately\r\n -w   perform device reset (DANGEROUS)\r\n -W   get\/set drive write-caching flag (0\/1)\r\n -x   obsolete\r\n -X   set IDE xfer mode (DANGEROUS)\r\n -y   put drive in standby mode\r\n -Y   put drive to sleep\r\n -Z   disable Seagate auto-powersaving mode\r\n -z   re-read partition table\r\n --dco-freeze      freeze\/lock current device configuration until next power cycle\r\n --dco-identify    read\/dump device configuration identify data\r\n --dco-restore     reset device configuration back to factory defaults\r\n --direct          use O_DIRECT to bypass page cache for timings\r\n --drq-hsm-error   crash system with a \"stuck DRQ\" error (VERY DANGEROUS)\r\n --fibmap          show device extents (and fragmentation) for a file\r\n --fibmap-sector   show absolute LBA of a specfic sector of a file\r\n --fwdownload            Download firmware file to drive (EXTREMELY DANGEROUS)\r\n --fwdownload-mode3      Download firmware using min-size segments (EXTREMELY DANGEROUS)\r\n --fwdownload-mode3-max  Download firmware using max-size segments (EXTREMELY DANGEROUS)\r\n --fwdownload-mode7      Download firmware using a single segment (EXTREMELY DANGEROUS)\r\n --idle-immediate  idle drive immediately\r\n --idle-unload     idle immediately and unload heads\r\n --Istdin          read identify data from stdin as ASCII hex\r\n --Istdout         write identify data to stdout as ASCII hex\r\n --make-bad-sector deliberately corrupt a sector directly on the media (VERY DANGEROUS)\r\n --prefer-ata12    use 12-byte (instead of 16-byte) SAT commands when possible\r\n --read-sector     read and dump (in hex) a sector directly from the media\r\n --security-help   display help for ATA security commands\r\n --trim-sectors    tell SSD firmware to discard unneeded data sectors (lba and count)\r\n --verbose         display extra diagnostics from some commands\r\n --write-sector    repair\/overwrite a (possibly bad) sector directly on the media (VERY DANGEROUS)\r\n\r\n<\/pre>\n<h2>Conclusion<\/h2>\n<p>Understanding the performance of your disk drives is crucial in managing and optimizing your Linux system, whether it&#8217;s a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-dedicated-server-hosting\/\">dedicated server<\/a>, a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-vps-hosting\/\">VPS server<\/a>, or a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-cloud-hosting\/\">cloud hosting<\/a> setup. The hdparm utility provides a straightforward and effective way to measure read speeds, while the dd command can be used to test write speeds.<\/p>\n<p>However, it&#8217;s important to remember that these tools only provide a snapshot of your disk&#8217;s performance at a given time. Disk performance can vary based on a variety of factors, including system load, running processes, and hardware health. Therefore, regular monitoring and multiple tests at different times can provide a more comprehensive view of your disk&#8217;s performance.<\/p>\n<p>By learning how to check disk read\/write speed in Linux, you can better understand your system&#8217;s performance and make informed decisions about system optimization, data management, and hardware upgrades. This knowledge is especially valuable for webmasters and website administrators who need to ensure optimal performance for their users.<\/p>\n<p>Remember, the key to effective system management is not only understanding how to perform these tests but also knowing how to interpret the results and apply this knowledge to improve system performance.<\/p>\n<p>If you have any comments or suggestions for improvements, please feel free to share them below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Checking the disk read and write speed is essential to understand the performance of your system and useful to determine the performance of your storage device, especially when it comes&#8230;<\/p>\n","protected":false},"author":6,"featured_media":4115,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2055,996],"tags":[1244,1254,2086,1536,2085,1713,1715],"class_list":["post-4110","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-linux","tag-centos","tag-centos-6-3","tag-hdparm","tag-linux","tag-performance","tag-rhel","tag-rhel-6"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/4110","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=4110"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/4110\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/4115"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=4110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=4110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=4110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}