mooc-course.com is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

How to Test Disk Speed in Linux?

How to Test Disk Speed in Linux?

5/5 - (1 vote)

Testing disk speed is crucial for optimizing system performance and troubleshooting issues in Linux. This guide will cover various methods to measure disk performance, including command-line tools and graphical utilities. We’ll explore how to run these tests, interpret the results, and apply this knowledge to real-world scenarios.

Test Disk Speed using Command-line in Linux

Using the dd Command

The dd command is a versatile tool that can be used to test disk write speed. Here’s how to use it:

  1. Open a terminal window.
  2. Run the following command:
    dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync

    This command writes a 1GB file to the disk and measures the write speed. The output will look something like this:

    1+0 records in
    1+0 records out
    1073741824 bytes (1.1 GB, 1.0 GiB) copied, 2.34563 s, 458 MB/s

    In this example, the write speed is 458 MB/s.To test read speed, first create a file, then read it:

    dd if=/tmp/test1.img of=/dev/null bs=8k

Using hdparm

hdparm is useful for testing read speeds, particularly for hard drives. Here’s how to use it:

  1. Install hdparm if it’s not already on your system:
    sudo apt-get install hdparm  # For Ubuntu/Debian
    sudo yum install hdparm      # For CentOS/RHEL
  2. Run the following command to test read speed:
    sudo hdparm -tT /dev/sda

    Replace /dev/sda with your disk identifier. The output will show cached reads and disk reads:

    /dev/sda:
     Timing cached reads:   21024 MB in  2.00 seconds = 10523.01 MB/sec
     Timing buffered disk reads: 304 MB in  3.01 seconds = 101.08 MB/sec

    The buffered disk read value (101.08 MB/sec in this example) represents the actual disk read speed.

Using fio (Flexible I/O Tester)

fio is a powerful tool for benchmarking disk I/O. Here’s how to use it:

  1. Install fio:
    sudo apt-get install fio  # For Ubuntu/Debian
    sudo yum install fio      # For CentOS/RHEL
  2. Create a configuration file named fio-test.ini:
    [global]
    ioengine=libaio
    iodepth=4
    size=2g
    direct=1
    runtime=60
    filename=/tmp/fio-test-file
    
    [seq-read]
    rw=read
    bs=128k
    
    [rand-read]
    rw=randread
    bs=4k
    
    [seq-write]
    rw=write
    bs=128k
    
    [rand-write]
    rw=randwrite
    bs=4k
  3. Run the test:
    fio fio-test.ini

This will perform sequential and random read/write tests. The results will include each test type’s IOPS, bandwidth, and latency.

See also  Recovering from an Accident: What to Do When Linux Deletes Your Home Directory

Graphical Method To Test Disk Speed in Linux

Using GNOME Disks Utility

For those who prefer a graphical interface, the GNOME Disks utility provides an easy-to-use benchmarking tool:

  1. Open the “Disks” application from your system menu.
  2. Select the disk you want to test.
  3. Click the menu button (three dots) and choose “Benchmark”.
  4. Select the type of benchmark (read or write) and start the test.

The utility will display a graph showing transfer rates across the disk.

Interpreting and Comparing Results

When interpreting disk speed test results, consider the following:

  • Sequential vs. Random: Sequential operations are typically faster than random ones.
  • Read vs. Write: Read speeds are often higher than write speeds.
  • IOPS (Input/Output Operations Per Second): Higher is better, especially for databases and virtualization.
  • Latency: Lower is better, crucial for responsiveness.

Compare your results to the manufacturer’s specifications. For SSDs, expect read speeds of 500-3500 MB/s and write speeds of 300-3000 MB/s, depending on the interface (SATA vs. NVMe). HDDs typically range from 80-160 MB/s for both reads and writes.

Best Practices and Tips

  • Run tests multiple times and average the results for accuracy.
  • Tests should be performed when the system is idle to avoid interference from other processes.
  • For SSDs, be aware of thermal throttling during extended tests.
  • Consider the impact of file systems: ext4 generally performs well for most use cases, while XFS can be better for large files.

Conclusion

Regular disk speed testing is essential for maintaining optimal system performance. By using a combination of command-line tools and graphical utilities, you can gain valuable insights into your disk’s capabilities and identify potential bottlenecks.

See also  What Programming Language is Linux Written In

Remember, disk performance can be affected by many factors, including hardware, file system choice, and system load. Use these tools to establish a baseline and track changes over time, helping you make informed decisions about storage upgrades or system optimizations.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free Worldwide Courses

Learn online for free

Enroll in Multiple Courses

Learn whatever your want from anywhere, anytime

International Language

Courses offered in multiple languages & Subtitles

Verified Certificate

Claim your verified certificate