dd

How to install dd

No need to install, almost all of the linux distributions have this tool, it is included in coreutils package on RHEL and Fedora.

Features and Functions

  • The most simply tool used to test disk performance.
  • Can set non-buffered I/O or buffered I/O to test disk read/write performance.
  • Can set block size for I/O units.

How to use dd

  1. Create a testfile under the disk which you want to test the performance with a proper size
# dd if=/dev/zero of=testfile bs=1M count=20000

Sequential read

  1. Test the sequential read performance with bs=1M and buffered IO
# dd if=testfile of=/dev/null bs=1M conv=fdatasync
  1. Test the sequential read performance with bs=1M and direct IO
# dd if=testfile of=/dev/null bs=1M iflag=direct

Sequential write

  1. Test the sequential write performance with bs=1M and buffered IO
# dd if=/dev/zero of=testfile bs=1M count=20000 conv=fdatasync
  1. Test the sequential write performance with bs=1M and direct IO
# dd if=/dev/zero of=testfile bs=1M count=20000 oflag=direct

Note:
When test buffered I/O, you must specify ‘oflag=sync’ or ‘conv=fdatasync’ option to write data from memory to disk.
For the write performance testing, we can also use ‘oflag=sync’, but this is not recommended. Because sync schedules the writes, but may return before the actual writing is done. But fdatasync will wait untill the data actual write to the disk.

Results analysis

Issue the dd command, command will give some output include throughput.

# dd if=testfile of=/dev/null bs=1M iflag=direct
200+0 records in
200+0 records out
209715200 bytes (210 MB) copied, 0.416249 s, 504 MB/s

209715200 bytes (210 MB) copied, 0.416249 s, 504 MB/s we see the Throughput is 504MB/s, the bigger the better.

The main parameters of dd

Command line options

  • if=FILE - read from FILE instead of stdin
  • of=FILE - write to FILE instead of stdout
  • iflag=FLAGS - FLAGS: direct, sync, dsync
  • oflag=FLAGS - FLAGS: direct, sync, dsync
  • bs=BYTES - read and write up to BYTES bytes at a time(K/M/G)
  • count=N - copy only N input blocks

FLAGS

  • sync - schedules the writes, but may return before the actual writing is done. It will also write the file metadata.
  • dsync - schedules the writes, but may return before the actual writing is done. It only write the file data.
  • fsync - schedules the writes, will wait untill the data actual write to the disk. It also write the file metadata.
  • fdatasync - schedules the writes, will wait untill the data actual write to the disk. It only write the file data.
  • direct - For non-buffered I/O.

Shortcomings

  • Can only test sequential read and sequential write performance.
  • Can only used to test disk performance.

Reference

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值