Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Jan 2022 17:26:12 -0800
From:      David Christensen <dpchrist@holgerdanske.com>
To:        freebsd-questions@freebsd.org
Subject:   zero filling a storage device (was: dd and mbr)
Message-ID:  <77680665-7ddb-23c5-e866-05d112339b60@holgerdanske.com>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?77680665-7ddb-23c5-e866-05d112339b60>