From nobody Sun Jan 16 00:08:24 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 6AD1C1959DD5 for ; Sun, 16 Jan 2022 00:08:28 +0000 (UTC) (envelope-from grog@lemis.com) Received: from lax.lemis.com (www.lemis.com [45.32.70.18]) by mx1.freebsd.org (Postfix) with ESMTP id 4JbwNq0v0Zz4S1r for ; Sun, 16 Jan 2022 00:08:27 +0000 (UTC) (envelope-from grog@lemis.com) Received: from eureka.lemis.com (121-200-11-253.79c80b.mel.nbn.aussiebb.net [121.200.11.253]) by lax.lemis.com (Postfix) with ESMTP id 993602809B; Sun, 16 Jan 2022 00:08:25 +0000 (UTC) Received: by eureka.lemis.com (Postfix, from userid 1004) id E5A6A2635C0; Sun, 16 Jan 2022 11:08:24 +1100 (AEDT) Date: Sun, 16 Jan 2022 11:08:24 +1100 From: Greg 'groggy' Lehey To: Daniel Feenberg Cc: "Kevin P. Neal" , David Christensen , freebsd-questions@freebsd.org Subject: Re: zero filling a storage device (was: dd and mbr) Message-ID: <20220116000824.GT61872@eureka.lemis.com> References: <77680665-7ddb-23c5-e866-05d112339b60@holgerdanske.com> <20220114023002.GP61872@eureka.lemis.com> 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: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9r3HF47jptiQlX4s" Content-Disposition: inline In-Reply-To: Organization: The FreeBSD Project Phone: +61-3-5309-0418 Mobile: +61-490-494-038. Use only as instructed. WWW-Home-Page: https://www.FreeBSD X-PGP-Fingerprint: 9A1B 8202 BCCE B846 F92F 09AC 22E6 F290 507A 4223 User-Agent: Mutt/1.6.1 (2016-04-27) X-Rspamd-Queue-Id: 4JbwNq0v0Zz4S1r X-Spamd-Bar: ++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of grog@lemis.com has no SPF policy when checking 45.32.70.18) smtp.mailfrom=grog@lemis.com X-Spamd-Result: default: False [2.20 / 15.00]; R_SPF_NA(0.00)[no SPF record]; ARC_NA(0.00)[]; FREEFALL_USER(0.00)[grog]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; NEURAL_SPAM_SHORT(1.00)[1.000]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; DMARC_NA(0.00)[FreeBSD.org]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(1.00)[1.000]; HAS_ORG_HEADER(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(1.00)[1.000]; MLMMJ_DEST(0.00)[freebsd-questions]; FORGED_SENDER(0.30)[grog@FreeBSD.org,grog@lemis.com]; RCVD_NO_TLS_LAST(0.10)[]; SIGNED_PGP(-2.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:20473, ipnet:45.32.64.0/19, country:US]; FROM_NEQ_ENVFROM(0.00)[grog@FreeBSD.org,grog@lemis.com]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N --9r3HF47jptiQlX4s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Friday, 14 January 2022 at 7:52:32 -0500, Daniel Feenberg wrote: > > Doesn't the filesystem code handle sparse files on its own? This man page: > > https://www.freebsd.org/cgi/man.cgi?du FWIW, it's easier to access this with 'man du'. > strongly implies that it does. A block of all zero bytes shouldn't > occupy hardly any disk space at all. Disk files are allocated in blocks. No data == no blocks. You can also write to a file, then lseek(1) to an address beyond the end of the file and write there. This will create a "sparse file": the intervening blocks will not be allocated. It's messy, though, because the allocation is by block, but writes don't need to adhere to block boundaries. Greg -- Sent from my desktop computer. See complete headers for address and phone numbers. This message is digitally signed. If your Microsoft mail program reports problems, please read http://lemis.com/broken-MUA.php --9r3HF47jptiQlX4s Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iEYEARECAAYFAmHjYfgACgkQIubykFB6QiNwZQCfQrX7qq1a13eJPRJgi+t8kK+F I7kAnj7Ojnee8/Qr+UpMeljtRy4LykcB =dh2W -----END PGP SIGNATURE----- --9r3HF47jptiQlX4s--