From nobody Fri Jan 14 01:26:12 2022 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id F12F119421A5 for ; Fri, 14 Jan 2022 01:26:21 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) Received: from holgerdanske.com (holgerdanske.com [IPv6:2001:470:0:19b::b869:801b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "holgerdanske.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JZkCd0P37z3FRK for ; Fri, 14 Jan 2022 01:26:20 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=holgerdanske.com; s=nov-20210719-112354; t=1642123573; bh=m+F26lS2nIZJBZ5h5n67i2xPaHLe6+LTprmdMFTq7VY=; h=Received:To:From:Subject:Message-ID:Date:User-Agent:MIME-Version: Content-Type:Content-Language:Content-Transfer-Encoding; b=uEL7CalYCONgIoToZ+N70Y5zVzjmiHFbx30Z/waPl5FGgl8gRgu9AYidDRWh63WwV 3kB1fsoaQ/WWOyEHKCVrdQbtG1pIbSP7EdhbpMhavftJOOBMlW2Bg92lr3Tlzjx8Qb d4X+BLaDxXGdXXdD2EIPKbdxAa89xTbLxJMn4DqOBCJxHJGwMpCDlZs8XOqo54eQpc 9BNr0yAI1Nul68aF9ANpjEs1P9y474FLemGeCY6EKPwuWEBeuXBPvx/Fr1OeH5AZv6 QJrxMroM5eqvtqBUMfdSTHiRws5SNsNLjz74v7zzCePFZvlhsAgGvur3HPX/MOSfme 91YVZNGEQ6r48hPFmiSNHt3eHYF8MYaJklBMltd8fBNSi/nPq4azMOlxgJRLClboKJ mWz9cGfm+jekpDJup4yQxAI8vzAHmdab1DVYfCuZd+QrNd7COo4V3Em3Me8Ay4prEa ZeBr13UFVOTTb9Odc5WGz12sGT53bk6lbpGPSU5EUn0qKx9hyBlYANxKx5iqBXccnZ OnQMTYEfKyRnkzyUuMJfCojpTU6g0Sl8/xdQC36kSDVQnm0EJemaBCvBeTR1FKuXH1 h0eistJs1Kwi78aSRJySz0pJwsiQN2T10ebbvIrz30haqw1XWNIUcyb7kUQQwugicu lEsYvvTRWiLZsiMNqW6SUqFM= Received: from 99.100.19.101 (99-100-19-101.lightspeed.frokca.sbcglobal.net [99.100.19.101]) by holgerdanske.com with ESMTPSA (TLS_AES_128_GCM_SHA256:TLSv1.3:Kx=any:Au=any:Enc=AESGCM(128):Mac=AEAD) (SMTP-AUTH username dpchrist@holgerdanske.com, mechanism PLAIN) for ; Thu, 13 Jan 2022 17:26:13 -0800 To: freebsd-questions@freebsd.org From: David Christensen Subject: zero filling a storage device (was: dd and mbr) Message-ID: <77680665-7ddb-23c5-e866-05d112339b60@holgerdanske.com> Date: Thu, 13 Jan 2022 17:26:12 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4JZkCd0P37z3FRK X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=holgerdanske.com header.s=nov-20210719-112354 header.b=uEL7CalY; dmarc=pass (policy=none) header.from=holgerdanske.com; spf=pass (mx1.freebsd.org: domain of dpchrist@holgerdanske.com designates 2001:470:0:19b::b869:801b as permitted sender) smtp.mailfrom=dpchrist@holgerdanske.com X-Spamd-Result: default: False [0.00 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[holgerdanske.com:s=nov-20210719-112354]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+a:november.he.net]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_MEDIUM(-1.00)[-0.997]; NEURAL_SPAM_SHORT(1.00)[1.000]; DKIM_TRACE(0.00)[holgerdanske.com:+]; DMARC_POLICY_ALLOW(-0.50)[holgerdanske.com,none]; NEURAL_SPAM_LONG(1.00)[1.000]; MLMMJ_DEST(0.00)[freebsd-questions]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N 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