Test the hard disk read/write speed in linux.

Source: Internet
Author: User
Tags ide hard drive

Test the hard disk read/write speed in linux.

After buying an ssd hard disk, I want to compare it with an ordinary mechanical disk. Because the desktop is installed with the ubuntu system, I just want to use the linux Command for a simple test.


The following are ssd performance data:

Test write:

xxx@WaitFish:~ > time dd if=/dev/zero bs=1024 count=1000000 of=1Gb.file1000000+0 records in1000000+0 records out1024000000 bytes (1.0 GB) copied, 3.78724 s, 270 MB/sreal    0m3.789suser    0m0.839ssys     0m2.527s

Reads data from null to files. The block size is 1024, and the number is 1000000.

Test read:

xxx@WaitFish:~ >time dd of=1Gb.file if=/dev/zero bs=1024 count=10000001000000+0 records in1000000+0 records out1024000000 bytes (1.0 GB) copied, 3.84934 s, 266 MB/sreal    0m4.009suser    0m0.852ssys     0m2.698s
Read data from a file to null to test read performance



Below is the speed of the mechanical Disk:

Write Performance:

sudo time dd if=/dev/zero bs=1024 count=1000000 of=1Gb.file1000000+0 records in1000000+0 records out1024000000 bytes (1.0 GB) copied, 69.5384 s, 14.7 MB/s1.62user 13.84system 1:09.56elapsed 22%CPU (0avgtext+0avgdata 704maxresident)k72inputs+0outputs (2major+221minor)pagefaults 0swaps
Read performance:

Xxx @ WaitFish:/media/xx/Add volume> sudo time dd of = 1 GB. file if =/dev/zero bs = 1024 count = 10000001000000 + 0 records in1_00 + 0 records out10241_00 bytes (1.0 GB) copied, 71.2378 s, 14.4 MB/s1.66user 14.34 system. 34 elapsed 22% CPU (0 avgtext + 0 avgdata 700 maxresident) k0inputs + 0 outputs (0 major + 224 minor) pagefaults 0 swaps

It seems that the difference is not a little bit, hahaha



What is the command for testing the read/write speed of a single hard disk on a linux server?

C cainiao assistant member tonytvb answers your questions (if you have any questions, please hi or ask my team ):

Function Description: displays and sets hard disk parameters.

Syntax: hdparm [-partition hiiqttvyyz] [-a <cache partition>] [-A <0 or 1>] [-c] [-d <0 or 1>] [-k <0 or 1>] [-K <0 or 1>] [-m <Number of partitions>] [-n <0 or 1>] [-p] [-P <Number of partitions >] [-r <0 or 1>] [-S <time>] [-u <0 or 1>] [-W <0 or 1>] [-X <transmission Mode>] [device]

Note: hdparm can be detected to display and set the parameters of the IDE or SCSI hard disk.

Test the reading speed of each hard disk to determine whether the hard disk is faulty

Run the following command in the server command window:

Hdparm-t/dev/hda (IDE Hard Drive)

Hdparm-t/dev/sda (SATA, SCSI, hard RAID card array)

Hdparm-t/dev/md0 (soft RAID device)

The test results should be greater than 40 M/s under no-load conditions, and the test results should be equal to> 20 M/s under load conditions. If the test results are extremely low, you need to use a dedicated hard disk detection tool to test whether the disk is faulty.

Parameters:

-A <cache partition> sets the number of partitions that are pre-stored in the block area when the file is read. If the <cache partition> option is not added, the current setting is displayed.

-A <0 or 1> enables or disables the cache function when reading files.

-C: sets the IDE32-bit I/O mode.

-C: detects the power management mode of the IDE hard disk.

-D <0 or 1> sets the DMA mode of the disk.

-F writes the data in the memory buffer to the hard disk and clarifies the buffer.

-G: displays the disk's magnetic track, Head, magnetic area, and other parameters.

-H: displays help.

-I displays the hardware specification information of the hard disk, which is provided by the hard disk itself at startup.

-I directly reads the hardware specification information provided by the hard disk.

-K <0 or 1> to reset the hard disk, retain the-dmu parameter settings.

-K <0 or 1> to reset the hard disk, retain the-APSWXZ parameter settings.

-M <number of magnetic partitions> sets the number of partitions accessed by multiple hard disk partitions.

-N <0 or 1> indicates an error that occurs when the hard disk is written.

-P: Set the PIO mode of the hard disk.

-P <number of magnetic partitions> sets the number of partitions in the cache of the hard disk.

-When executing subsequent parameters, q does not display any information on the screen.

-R <0 or 1> sets the read/write mode of the hard disk.

-S <time> sets the waiting time before the hard disk enters power-saving mode.

-T to evaluate the Read efficiency of the hard disk.

-T the reading efficiency of the flat hard disk cache.

-U <0 or 1> allows other interruption requests to be executed simultaneously during hard disk access.

-V displays the hard disk settings.

-W <0 or 1> sets the hard disk write cache.

-X <transmission mode> sets the transmission mode of the hard disk.

-Y enables the IDE hard drive to power-saving mode.

-Y: Enable the IDE hard drive to sleep.

-Z: Disable Automatic power saving for some Seagate hard disks .... Remaining full text>
 
Linux shell hard disk file read/write check test script

When a read/write failure occurs, the return value of dd cannot be found. If this cannot be understood, it makes no sense to check whether it is correct or not (I don't know whether it is dd Or md5sum). If you forget it, you just need to check it and change it.

#! /Bin/bash

Infile = "$1"
Cycle = 0
Copy = 0
Err = 0

If ["$ #"-ne 1] | [! -F "$1"]
Then
Echo "Usage: test <infile>"
Exit 1;
Fi

Echo-e "<> warning <>: This test program has serious damage to the disk. Please run it with caution. "
Echo-e "Press Crtl + C to terminate the test"

Echo-e "start testing? (Y/n) y: \ c"
While read-r answer </dev/tty
Do

If ["$ answer" = 'n'] | ["$ answer" = 'n']
Then
Echo "Result: $ cycle round $ copy times in total, read/write errors $ err times"
Rm-f $ {infile }_*
Exit 0
Fi

Let cycle ++
Echo "==================================== cycycle ============== =========================="
Rm-f "$ infile "_*
Sync

Let copy ++
# For convenience, select the first partition.
While ["$ (df-k | sed-n '3q; 2 s/* // g; 2p '| cut-d'-f 4)"-gt 1]
Do
Echo "=========== copy $ copy =============="
Outfile = "$ {infile }_$ {copy }"
Dd if = "$ infile" of = "$ outfile"

# If the return code of the dd command encounters a read failure or write failure is untraceable, but it is certainly not 0,
Another implementation method is to use the md5sum -- status test. However, this method seems to have caused the read/write ratio to change.
If ["$? "-Ne 0]
Then
Let err ++
Fi

Let copy ++... the remaining full text>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.