7

I want to know how many bytes per second can I write to the disk and read from it.

How can I do that on linux machine?

Roman
  • 197
  • 3
  • 6
  • For a noob friendly version of this you can find it at http://vpstip.com/how-to-check-disk-speed-easily-in-linux/ –  Jan 08 '14 at 03:10
  • This is a popular question that wound up been re-asked many times e.g. https://unix.stackexchange.com/q/108838/109111 , https://stackoverflow.com/q/1198691/2732969 , https://serverfault.com/q/219739/203726 and https://askubuntu.com/q/87035/740413 all have answers relevant to this question. – Anon Jul 29 '19 at 06:12

5 Answers5

7

Use a benchmark tool like bonnie(++). It's easy to install on about every distribution, and since it measures different aspects, you get quite a good picture how the system performs in a given situation.

If you just want to use basic tools, you could use dd:

For write speed:

dd if=/dev/zero of=outputfile bs=512 count=32M

(The product of bs and count should be at least twice your RAM size)

For read speed:

dd if=outputfile of=/dev/null

Remember that this is a very rough estimate and measures a situation that is unlikely to occur in normal operations.

Sven
  • 97,248
  • 13
  • 177
  • 225
  • Can I measure the necessary info just with linux commands? – Roman Dec 14 '10 at 14:09
  • 1
    +1 You might want to pick a block size larger than 1 sector unless your after a specific performance metric. I normally use bs=1m and count=1k (the 512 and 32m will fit in RAM and any raid controller's cache easily.). Same goes for read operations. Note that `dd` will give you pretty synthetic numbers unless you know your IO load very well and use very specific numbers. – Chris S Dec 14 '10 at 15:50
  • You should also use oflag=direct to bypass the filesystem cache. This obviates the need to write out twice as much data as your available ram as well, which means your tests are quicker to run – Daniel Lawson Dec 17 '10 at 03:08
3

I would just use hdparm to measure the read speeds of the drives:

hdparm -t /dev/sda

you can test read speeds on formatted drives with data on it but be careful with writing as if wrongly used can corrupt data.

Hope that helps, RayQUang

RayQuang
  • 664
  • 1
  • 9
  • 16
1

Iozone, bonnie++, nmon (realtime) - they all work.

ewwhite
  • 194,921
  • 91
  • 434
  • 799
1

Josh Berkus gave a pretty detailed talk at pgCon 2009 on performance tuning; the first half or so is just dedicated to measuring disk I/O and solutions. It's big and long, but you only need to watch it once to get an idea of what sorts of things to think about.

Also take a look at the benchmarking video, which covers much of the same content.

jldugger
  • 14,122
  • 19
  • 73
  • 129
1

iometer has also been around for a while.

JakeRobinson
  • 2,886
  • 17
  • 26