zero filling a storage device (was: dd and mbr)
- Reply: Greg 'groggy' Lehey : "Re: zero filling a storage device (was: dd and mbr)"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 14 Jan 2022 01:26:12 UTC
On 1/11/22 2:02 AM, Roderick wrote: > dd if=/dev/zero of=/dev/da0 On 1/13/22 12:32 AM, Roderick wrote: > > On Thu, 13 Jan 2022, Greg 'groggy' Lehey wrote: > >> As others have suggested, use bs=64k. Otherwise dd does an IO for >> every single sector. The speedup is really in the order of 100x. > > I used bs=1m. I hope that was also OK. In any case faster than without it. Suppose I have a storage device with M blocks of size B bytes each. Some of the blocks contain non-zero bytes and other blocks contain only zero bytes. Suppose I have a program with a memory buffer of N blocks filled with zero bytes, where N < M. If the program writes the buffer to the storage device starting at block-aligned location P, where P + N * B <= M * B, will the storage device write zero bytes to the storage device blocks that already contain only zero bytes? Is the answer different for a HDD, an SSD, a USB flash drive, an SD card, a compact flash card, etc.? David