You are not logged in.

#1 2014-07-14 14:10:31

Spider.007
Member
Registered: 2004-06-20
Posts: 1,176

[SOLVED] Why does `dd if=/dev/zero of=/dev/sdc` cause disk-reads?

I have noticed this on multiple occasions. When wiping a drive, but also when writing other content to it; both atop and iotop show that the disk is reading and writing the same amount of data. This feels like it is slowing down the writing I want it to do. Is there an option in dd I'm missing? Happens on multiple machines, kernels and disks. It feels like the linux-kernel is verifying what was written to the disk; but I cannot find any documentation on this

Last edited by Spider.007 (2014-07-15 07:43:21)

Offline

#2 2014-07-14 16:05:12

rgb-one
Member
Registered: 2013-09-15
Posts: 19

Re: [SOLVED] Why does `dd if=/dev/zero of=/dev/sdc` cause disk-reads?

use bs=4M option with dd. This increases the block size to 4 "M"egabytes so reads and writes are faster. You can even use bs=8M.
I haven't tried above bs=8M so maybe you can look into that.

dd if=/dev/zero of=/dev/sdc bs=8M

Offline

#3 2014-07-14 16:24:04

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [SOLVED] Why does `dd if=/dev/zero of=/dev/sdc` cause disk-reads?

That definitely doesn't seem right. Here's what I see in iotop:

 1846 be/4 root        0.00 B/s  104.04 M/s  0.00 % 91.64 % dd if=/dev/zero of=/dev/sdc bs=1M

But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2014-07-15 07:43:08

Spider.007
Member
Registered: 2004-06-20
Posts: 1,176

Re: [SOLVED] Why does `dd if=/dev/zero of=/dev/sdc` cause disk-reads?

Okay it does indeed seem the blocksize is to blame. Without it; I get ~ 30 MiB/s; when I add it the speed increases to ~ 200 MiB/s.
I'd never expect the impact of a missing blocksize to be this big; it seems the default isn't optimal

Offline

#5 2014-07-15 09:16:48

mich41
Member
Registered: 2012-06-22
Posts: 796

Re: [SOLVED] Why does `dd if=/dev/zero of=/dev/sdc` cause disk-reads?

The default dd block size is 512 bytes, which is the traditional size of HDD sectors.

However, most of the time, Linux performs disk IO in 4kB blocks. When you submit a sequence of 512 byte write requests, it reads a 4kB block, modifies it part-by-part in 512 byte chunks, writes it back, reads another 4kB block and so on.

Setting bs to at least 4kB should eliminate the reads. Increasing it to few MB may improve performance slightly further by reducing the number of individual write requests and hence the time spent by the kernel on "understanding" them.

Last edited by mich41 (2014-07-15 09:31:43)

Offline

#6 2014-07-15 14:19:42

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [SOLVED] Why does `dd if=/dev/zero of=/dev/sdc` cause disk-reads?

...and best answer goes to mich41!


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

Board footer

Powered by FluxBB