Re: zero filling a storage device (was: dd and mbr)

From: Greg 'groggy' Lehey <grog_at_FreeBSD.org>
Date: Sun, 16 Jan 2022 00:08:24 UTC
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