Checking disk performance on linux

Disk Speed Test (Read/Write): HDD, SSD Performance in Linux

From this article you’ll learn how to measure an input/output performance of a file system on such devices as HDD, SSD, USB Flash Drive etc.

I’ll show how to test the read/write speed of a disk from the Linux command line using dd command.

I’ll also show how to install and use hdparm utility for measuring read speed of a disk on Linux Mint, Ubuntu, Debian, CentOS, RHEL.

To get the accurate read/write speed, you should repeat the below tests several times (usually 3-5) and take the average result.

Cool Tip: How to choose SSD with the best quality/price relation! Read more →

dd: TEST Disk WRITE Speed

Run the following command to test the WRITE speed of a disk:

$ sync; dd if=/dev/zero of=tempfile bs=1M count=1024; sync 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 3.28696 s, 327 MB/s

dd: TEST Disk READ Speed

The file tempfile , that has just been created by the previous command, was cached in a buffer and its read speed is much higher then the real read speed directly from the disk.

To get the real speed, we have to clear cache.

Run the following command to find out the READ speed from buffer:

$ dd if=tempfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 0.159273 s, 6.7 GB/s

Clear the cache and accurately measure the real READ speed directly from the disk:

$ sudo /sbin/sysctl -w vm.drop_caches=3 vm.drop_caches = 3 $ dd if=tempfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 2.27431 s, 472 MB/s

dd: TEST Read/Write Speed of an External Drive

Cool Tip: Have added a new drive to /etc/fstab ? No need to reboot! Mount it with one command! Read more →

To check the performance of some External HDD, SSD, USB Flash Drive or any other removable device or remote file-system, simply access the mount point and repeat the above commands.

Or you can replace tempfile with the path to your mount point e.g.:

$ sync; dd if=/dev/zero of=/media/user/MyUSB/tempfile bs=1M count=1024; sync

Reminder: All the above commands use the temporary file tempfile . Don’t forget to delete it when you complete the tests.

hdparm: Test HDD, SSD, USB Flash Drive’s Performance

hdparm is a Linux command line utility that allows to set and view hardware parameters of hard disk drives.

And it can also be used as a simple benchmarking tool that allows to quickly find out the READ speed of a disk.

hdparm is available from standard repositories on the most Linux distributions.

Install hdparm depending on your Linux distribution.

Читайте также:  Install applet linux mint

Cool Tip: Troubleshooting an issue with a hard drive performance? It will be a good idea also to test download/upload Internet speed. It can be easily done from the Linux command line! Read more →

On Linux Mint, Ubuntu, Debian:

$ sudo apt-get install hdparm

On CentOS, RHEL:

Run hdparm as follows, to measure the READ speed of a storage drive device /dev/sda :

$ sudo hdparm -Tt /dev/sda /dev/sda: Timing cached reads: 16924 MB in 2.00 seconds = 8469.95 MB/sec Timing buffered disk reads: 1386 MB in 3.00 seconds = 461.50 MB/sec

18 Replies to “Disk Speed Test (Read/Write): HDD, SSD Performance in Linux”

williamj@SilverK:~$ sync; dd if=/dev/zero of=tempfile bs=1M count=1024; sync 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.313688 s, 3.4 GB/s williamj@SilverK:~$ dd if=tempfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.093416 s, 11.5 GB/s williamj@SilverK:~$ sudo /sbin/sysctl -w vm.drop_caches=3 [sudo] password for williamj: vm.drop_caches = 3 williamj@SilverK:~$ dd if=tempfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.7639 s, 1.4 GB/s

“Reminder: All the above commands use the temporary file tempfile. Don’t forget to delete it when you complete the tests.”
I can not find any place where you instruct as to how to delete the tempfile. How is this done safely?

go to directory where you executed the command, in terminal:
““rm tempfile““
or in a gui select the file and delete it.

I must have done something wrong. I tested first with bs=4k and count=256k.
It finished quickly.
Afterwards I decided myself to alter the parameters like so: bs=1M and count=256k
I didn’t know exactly what I was doing. I left it running not having slightest hunch if it’s wrong to interrupt it via Ctrl-C. It run approximately 1000 seconds having written almost 100GB of all 150GB free on the SSD. Only then I’ve read the man pages searching for clues but still didn’t found. So I have a couple of questions if kindly allowed. That ‘k’ at the end of count I am not sure of it’s meaning or even if it makes sense. I have to also ask what would have happened if the command filled the whole free space? Would it have stopped by itself with message/error? Was it dangereous for an ssd doing this. The fact I performed it from sysresccd on ssd with Windows installed has any effect on outcome?
I mean the if = is it from the RAM memory? I specified an of= on the ssd after mounting it like /mnt/windows/some.output.file. Is the way I did it significant for the results?

@JON > bs=4k and count=256k
k means what it always means: about 1,000, but in the case of computers (here), usually 1024. “bs” means block size, “count” means number of blocks. So this means write 4k x 256k bytes. 1k x 1k = 1 megabyte (about 1,000 x about 1,000 = about 1,000,000). How many megabytes? Since we already took care of the ‘k’s; 4x 256 = 1024 (aka about 1000, or 1k again.) What’s 1k x 1k x 1k? 1 gigabyte (about 1,000,000,000.) You wrote 1 gigabyte of zeros. Therefore, > bs=1M and count=256k 1M = (1k x 1k)
(1k x 1k) x 1k(the k from “count”) = 1 gigabyte
1 gigabyte x 256 = 256 gigabytes. You were writing 256 gigabytes of zeros. Your drive is only 150 gigabytes in size. It won’t hurt your drive, it will just delete everything on your drive. When it fills your drive, it will stop. The “if” is not from ram, it is a program (/dev/zero) in your system disguised as a file but whenever it is read is just endless zeros.

Читайте также:  Linux parted расширить диск

How to check sdb drive?
Should I use /dev/sdb instead of /dev/zero here:
sync; dd if=/dev/zero of=/media/user/MyUSB/tempfile bs=1M count=1024; sync
?

I think you missed the best software package for this kind of tests. It’s called fio:
https://github.com/axboe/fio/

It’s not accurate. The second sync does not influence the measurement (it’s being run after dd reports the results) and thus it’s influenced by caching. If you try the same test with 4096 or 8192 megs, you’ll have worse results (but closer to the reality). One way to correct for this is measuring the whole process with the time command and then doing the division manually. E.g.:
# time (sync; dd if=/dev/zero of=tempfile bs=1M count=8192; sync) You’ll see that dd will report a higher throughput, but you can then divide 8192 with whatever seconds time comes up with.

You need `conv=fdatasync` in your dd commands to include flush and sync time. Otherwise the results will be way too high, as others have mentioned.

/dev/sdb2:
Timing cached reads: 16830 MB in 1.99 seconds = 8454.99 MB/sec
Timing buffered disk reads: 434 MB in 3.01 seconds = 144.27 MB/sec

Hello, after doing some tests with different “GB” my storage on NVMe was filled with 7% (56GB), can I delete that storage or stay there permanently?

Источник

How to Check Hard Disk Performance on Linux?

Hard disk performance is tested to diagnose issues, optimistic performance, and reliability of the disk.

It helps the user to detect if any problem is causing the system’s performance. There are a variety of ways in Linux to check the hard disk performance, such as “hdparm”, “dd”, “iostat,” or “Disks” tools.

This post will demonstrate the methods for checking the hard disk performance in Linux.

  • Method 1: Through “hdparm” Utility
  • Method 2: Through “dd” Utility
  • Method 3: Through “iostat” Utility
  • Method 4: Through “Disks” (GUI)

Method 1: Through the “hdparm” Utility

The “hdparm” is the abbreviation of Hard Disk Parameter, it is the command line examined to manage the disk services in Linux. Install “hdparm” by running the following command:

$ sudo apt install hdparm #For Debian/Ubuntu $ sudo yum install hdparm #For Fedora/CentOS/RHEL

To measure the read speed of the hard disk, the following command is considered:

The command is described as:

  • The “hdparm” with sudo permission.
  • T” option to read the buffer cache and “t” flag to test it.
  • /dev/sda” is the hard disk name.

The cache read speed of the hard disk is “5958.31 MB/sec”, and the read speed for the buffer is “391.78 MB/sec”.

Note: The sudo permission is required for the “hdparm” command

Method 2: Through the “dd” Utility

The “dd” is the built-in utility of Linux that enables the user to copy and convert files or the raw data from one source to another. It can be helpful for testing and measuring the speed of the hard disk by copying some raw data. The following command tests the read and writes speed of the hard disk:

$ dd if=/dev/zero of=/tmp/output bs=8k count=10k; rm -f /tmp/output

The command is described as

Читайте также:  Linux console commands log

  • dd” command to copy the raw data.
  • if=/dev/zero” to read null characters from the special file “/dev/zero”.
  • of=/tmp/output” to copy the null characters in the “output” file.
  • bs=8k” tells each block size of 8KB.
  • count =10k” defining the number of blocks to write.
  • rm -f /tmp/output” command removing the file after testing.

The copy speed of the hard disk is “190 MB/s” which is considered a good performance.

A standard hard disk (HDD) has a read and write speed between 80MB/s to 160MB/s. While the solid state disk (SSD) has a speed between 200MB/s to 500MB/s

Method 3: Through the “iostat” Utility

The “iostat” is a utility of Linux to monitor the performance of the hard disk that comes with the installation of “sysstat.” To install “sysstat” the following command is used:

$ sudo apt install sysstat #For Debian/Ubuntu $ sudo yum install sysstat #For Fedora/CentOS/RHEL

To check the performance of the disk, run the “iostat” with “y” flag for displaying the extended statistics of the device utilization:

The number of Kilobytes of read and write per second for each device is printed.

Note: The “dnf” support can be obtained on CentOS via the command:

Method 4: Through the “Disks” (GUI)

Another method to check the performance of the hard disk is to use the “gnome-disks” tool of Linux. Using this, the user can test the benchmark of the hard disk. To install it in the Linux operations system, consider the following command:

$ sudo apt install gnome-disk-utility #For Debian/Ubuntu $ sudo dnf install gnome-disk-utility #For Fedora/CentOS/RHEL $ sudo pacman -s gnome-disk-utility #For Arch

Note: if you are not able to install “genome-disk-utility” on CentOS, install the “dnf” support:

Go through the following steps to do a benchmark of the hard disk.

Step 1: Launch the “gnome-disks”

Search for the “disks” tool from the software and launch it:

Step 2: Choose the Benchmark Option

Click on the 3 dots from the top right side and click on the “benchmark” option:

Step 3: Start the Benchmark

From the given interface, click on the “Start Benchmark” option:

Give the number of samples and size of each sample in MB as per your choice and start the benchmarking:

The benchmarking process is started and will take some time to complete it.

Verify the Results

Once the benchmark is completed, the user can see the result of read/write speed result:

The average read rate is 361.8MB/s.

Conclusion

To check the hard disk performance of the Linux system, the user can consider the utilities such as “hdparm”, “dd ”, or “iostat”. The “Disks” tool can also be used to check the performance of the hard disk. This write-up has illustrated the various ways to check the hard disk performance.

Источник

Оцените статью
Adblock
detector