Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

First command

sudo dd if=/dev/zero of=/dev/sda

second command

sudo dd if=/dev/zero of=/dev/sda bs=1M

I am formatting my pc for 4 hours with first code but it didn't finish.

Is the first code wrong?

What is the difference?

share|improve this question
Why do you need to fill with zeros you hard drive, a regular format isn't enough? – ThiagoPonte Dec 21 '12 at 12:39
up vote 2 down vote accepted

The default block size for dd is 512 Bytes, with the second command you tell dd to use 1MB block size.

What's block size?

A block is a unit measuring the number of bytes that are read, written, or converted at one time. Command line options can specify a different block size for input/reading (ibs) compared to output/writing (obs), though the block size (bs) option will override both ibs and obs. The default value for both input and output block sizes is 512 bytes (the block size of Unix block devices). The count option for copying is measured in blocks, as are both the skip count for reading and seek count for writing. Conversion operations are also affected by the "conversion block size" (cbs).

For some uses of the dd command, block size may have an effect on performance. For example, when recovering data from a hard disk, a small block size will generally cause the most bytes to be recovered. For greater speed during copy operations, a larger block size may be used. When dd is used for network transfers, the block size may have an impact on packet size, depending on the network protocol used.


share|improve this answer
thank you. this would be really useful. – halit cetin Dec 21 '12 at 12:15

First command uses 512 byte blocks, whereas the second uses 1MB blocks. Actually a 4kB blocksize will do the trick in most cases as the disk uses 4kB blocksize on hardware level.

What happens in the first case is the following (simplified):

  1. read a 4kB block from disk into memory buffer
  2. replace 512 bytes in memory buffer
  3. write 4kB buffer to disk
  4. read 4kB block from disk into memory
  5. replace next 512 bytes in buffer
  6. write 4kB block to disk

... replacing a 4kB block requires 8 reads from disk and 8 writes to disk.

I guess you get the image for what happens when you increase block size to 4kB or larger (preferably multiple of 4kB) and how that increases speed. It doesn't have to read the disk any more, because entire blocks are written.

On top of that speed up, it is quite likely that the PC is now delivering data fast enough to the disk, that it can probably write consecutive block one after the other, without having to wait for the rotating platter to do a full revolution until the right block appears under the heads.

share|improve this answer

Argument bs=1M in second command means number of bytes read and then written. So, when you run dd with this argument, 1 MB will be read from /dev/zero, and then 1 MB will be written to /dev/sda. When you don't have the argument, default value for byte number is used, I think it is 512 bytes. This number of bytes is much smaller, so more reading and writing is needed to complete requested operation and it will be slower.

share|improve this answer
thank you for answer. i found what i want with this. – halit cetin Dec 21 '12 at 12:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.