In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to use the dd command to test the performance of the hard disk in the Linux system". In the operation of actual cases, many people will encounter this dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Basic use of the dd command
Dd: copies a file with a block of the specified size and performs the specified conversion at the same time.
Note: if the specified number ends with the following characters, it will be multiplied by the corresponding number: bouncy 512
Parameter comments:
If= file name: enter the file name, which defaults to standard input. That is, specify the source file.
< if=input file >Of= file name: output file name, default to standard output. That is, specify the destination file.
< of=output file >Ibs=bytes: read bytes bytes at a time, that is, specify a block size of bytes bytes.
Obs=bytes: output bytes bytes at a time, specifying a block size of bytes bytes.
Bs=bytes: set the read / output block size to bytes bytes at the same time.
Cbs=bytes: convert bytes bytes at a time, that is, specify the conversion buffer size.
Skip=blocks: skip blocks blocks from the beginning of the input file before you start copying.
Seek=blocks: skip blocks blocks from the beginning of the output file before you start copying.
Note: it is usually only valid when the output file is a disk or tape, that is, when backing up to a disk or tape.
Count=blocks: only blocks blocks are copied, with the block size equal to the number of bytes specified by ibs.
Conv=conversion: converts the file with the specified parameters.
Ascii: converting ebcdic to ascii
Ebcdic: converting ascii to ebcdic
Ibm: converting ascii to alternate ebcdic
Block: convert each line to a length of cbs, and fill in the gaps with blanks
Unblock: make the length of each line cbs, and fill the insufficient parts with blanks
Lcase: convert uppercase characters to lowercase characters
Ucase: convert lowercase characters to uppercase characters
Swab: swap each pair of bytes of input
Noerror: don't stop when something goes wrong
Notrunc: output files are not truncated
Sync: populate each input block into ibs bytes, and fill in the shortfalls with NUL characters.
Use the dd command to test the performance of the hard disk iBando
How do I use the dd command to test the performance of my hard drive? How to test the read and write speed of the hard disk under the linux operating system?
You can use the following command to perform a simple Isign O performance test on a Linux or Unix-like operating system.
Dd command: it is used to test the write performance of hard disk devices in Linux and Unix-like systems.
Hparm command: it is used to get or set hard disk parameters on Linux-based systems, including testing read performance and cache performance.
In this guide, you will learn how to use the dd command to test hard disk performance.
Use the dd command to monitor the read and write performance of the hard drive:
Open the shell terminal.
Or log in to the remote server via ssh.
Use the dd command to measure the server's throughput (write speed) dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
Use the dd command to measure server latency dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync
Understand the options for the dd command
In this example, I will use the RAID-10 (Adaptec 5405Z with SAS SSD) server array with Ubuntu Linux 14.04 LTS system to run. The basic syntax is:
The code is as follows:
Dd if=/dev/input.file of=/path/to/output.file bs=block-size count=number-of-blocks oflag=dsync
# # GNU dd Syntax # #
Dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
# # another GNU dd syntax # #
Dd if=/dev/zero of=/tmp/testALT.img bs=1G count=1 conv=fdatasync
Sample output:
Please note that in this experiment, we write a G of data, and we can find that the throughput of the server is 135 MB/s.
If=/dev/zero (if=/dev/input.file): used to set the input file name read by the dd command.
Of=/tmp/test1.img (of=/path/to/output.file): the name of the output file to which the dd command writes input.file.
Bs=1G (bs=block-size): sets the size of the block read by the dd command. In the example, it is 1 G.
Count=1 (count=number-of-blocks): the number of blocks read by the dd command.
Oflag=dsync (oflag=dsync): use synchronous iBandO. Don't omit this option. This option can help you remove the influence of caching so that it can give you accurate results.
Conv=fdatasyn: this option has the same meaning as oflag=dsync.
In the following example, a total of 1000 writes were made, each writing 512 bytes to get the latency of the RAID10 server:
The code is as follows:
Dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync
Sample output:
1000000 records in
1000000 records out
512000 bytes (512 kB) copied, 0.60362 s, 848 kB/s
Note that server throughput and latency also depend on the server / application load. So I recommend that you run tests on a server that has just been rebooted and is in peak time to get more accurate metrics. Now you can compare these test results with each other on all your devices.
Why is the throughput and latency of the server so poor?
A low number doesn't mean you're using poor hardware. It may be caused by the controller cache of the hardware RAID10.
Use the hdparm command to view the read speed of the hard disk cache.
I recommend that you run the following command 2-3 times to test the read performance of the device for reference and comparison:
The code is as follows:
# read performance test of hard disk with cache-/ dev/sda #
Hdparm-t / dev/sda1
# # or # #
Hdparm-t / dev/sda
Then run the following command 2-3 times to check the read performance of the cache:
The code is as follows:
# # Cache Reading benchmark-/ dev/sda #
Hdparm-T / dev/sda1
# # or # #
Hdparm-T / dev/sda
Or simply combine the two tests:
The code is as follows:
Hdparm-Tt / dev/sda
Sample output:
Please note again that because of the caching properties of file operations, you will always see a high read speed.
Use the dd command to test the read speed
To get accurate read test data, first run the following command before the test to set the cache to invalid:
The code is as follows:
Flush
Echo 3 | sudo tee / proc/sys/vm/drop_caches
Time time dd if=/path/to/bigfile of=/dev/null bs=8k
Examples on notebooks
Run the following command:
The code is as follows:
# Notebook throughput of Debian system with Cache #
Dd if=/dev/zero of=/tmp/laptop.bin bs=1G count=1 oflag=direct
# invalidate cache #
Hdparm-W0 / dev/sda
# Notebook throughput of Debian system without Cache #
Dd if=/dev/zero of=/tmp/laptop.bin bs=1G count=1 oflag=direct
The example of Apple OS X Unix (Macbook pro)
GNU dd has many more options but OS X/BSD and Unix-like dd command need to run as follows to test real disk I/O and not memory add sync option as follows:
There are many other options for the GNU dd command, but in OS X/BSD and Unix-like, the dd command needs to be executed as follows to test the true Icano performance of the hard disk without memory address synchronization:
The code is as follows:
# # run this command 2-3 times to get better results #
Time sh-c "dd if=/dev/zero of=/tmp/testfile bs=100k count=1k & & sync"
Sample output:
1024000 records in
1024000 records out
104857600 bytes transferred in 0.165040 secs (635346520 bytes/sec)
Real 0m0.241s
User 0m0.004s
Sys 0m0.113s
My Macbook Pro write speed is 635346520 bytes (635.347MB/s).
Don't like to use the command line?
You can use disk utility (gnome-disk-utility) on Linux or Unix-based systems to get the same information. The picture below was captured on my Fedora Linux v22 VM.
Graphical method
Click the "Activites" or "Super" button to switch between desktop and Activites views. Enter "Disks"
Select your hard drive on the left panel, click the configure button, and then click "Benchmark partition":
Finally, click "Start Benchmark..." Button (you may need to enter an administrator username and password):
If you ask, which command and method do I recommend?
I recommend using the dd command (time sh-c "dd if=/dev/zero of=/tmp/testfile bs=100k count=1k & & sync) on all Unix-like systems
If you are using GNU/Linux, use the dd command (dd if=/dev/zero of=/tmp/testALT.img bs=1G count=1 conv=fdatasync)
Make sure that every time you use it, you adjust the count and bs parameters to get better results.
The GUI method is only suitable for Linux/Unix notebook users whose desktop system is Gnome2 or Gnome3.
This is the end of the content of "how to use the dd command to test hard disk performance in the Linux system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.