18

In linux:

$ dd if=/dev/null of=mysparse seek=1G count=0
$ du -b mysparse
549755813888    mysparse
$ du -B1 mysparse
0       mysparse

In windows I have been playing with fsutil but I can not get the size on disk to be smaller than the size in the file properties.

sabgenton
  • 684

3 Answers3

23
Type NUL > temp
FSUtil Sparse SetFlag temp
FSUtil Sparse SetRange temp 0 0x40000000
FSUtil File SetEOF temp 0x40000000

It Creates a New File, then Sets the Sparseness Flag for it, then Sets that specific Range to Sparse. The size is in bytes.

You can also refer to the documentation: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-sparse

user541686
  • 23,629
5

May be this will help you: "SparseChecker" - manages sparse files on Windows NTFS It allows to operate with files, not with individual blocks of files as "fsutil" does.

benok
  • 165
  • 1
  • 7
opal
  • 51
2

What @Mehrdad said is correct.

However, whatever you write to the file (even ranges of zero) would be considered data to the operating system (and thus space allocated) and only FSCTL_SET_ZERO_DATA() would allow non-space occupying zeros to be written.

fsutil sparse setflag [file]

would allow a file to be set as sparse file.

bubu
  • 10,029