2016年3月2日 星期三

磁碟效能測試工具: dd

1. dd簡介
dd is a command-line utility for Unix and Unix-like operating systems whose primary purpose is to convert and copy files.

2. dd參數說明
if=FILE
    read from FILE instead of stdin

of=FILE
    write to FILE instead of stdout

bs=BYTES
    read and write up to BYTES bytes at a time

count=N
    copy only N input blocks


Each CONV symbol may be:
    fdatasync
        physically write output file data before finishing
3. 效能測試
3-1. Write Zero Data
To get the accurate read/write speed, you should repeat the below tests several times (usually 3-5) and take the average result.
$ dd if=/dev/zero of=testfile bs=1M count=1024 conv=fdatasync
The flag conv=fdatasync tells dd to sync the write to disk before it exits. Without this flag, dd will perform the write but some of it will remain in memory, not giving you an accurate picture of the true write performance of the disk.

3-2. Read Zero Data
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 hard drive. To get the real speed, we have to clear cache.
$ sudo /sbin/sysctl -w vm.drop_caches=3

$ dd if=testfile of=/dev/null bs=1M count=1024

3-3. Write Random Data
$ dd if=/dev/urandom of=testfile bs=1M count=1024 conv=fdatasync

3-4. Read Random Data
$ sudo /sbin/sysctl -w vm.drop_caches=3

$ dd if=testfile of=/dev/null bs=1M count=1024

4. 參考來源
http://manpages.ubuntu.com/manpages/wily/en/man1/dd.1.html
https://wiki.archlinux.org/index.php/Benchmarking/Data_storage_devices
https://romanrm.net/dd-benchmark
http://www.blackmoreops.com/2014/10/28/delete-clean-cache-to-free-up-memory-on-your-slow-linux-server-vps/

沒有留言:

張貼留言