Page 1 of 1

How to deal with “sparse files” on NTFS (native solution) Rate Topic: -----

#1 MirrorFish   User is offline

  • New D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 27
  • Joined: 29-March 11

Posted 18 October 2011 - 07:44 AM

Imagine the image of the disk volume stored on your file system (by some backup/migration solution, for example). Some sectors are in use, some are dirty after insecure file deletion and others are just filled with zeros. Let's leave alone these insecure/dirty sectors and consider only two remaining groups of sectors: occupied and free ones. So how the disk image is to be represented as a file on the file system ? I guess the reader should know an answer at once: free sectors – filled with zeros, occupied sectors – depending on what has been written to them.

NTFS (like most of nowadays file systems) provides the ability to skip chunks of data with continuous zero bytes because the starting point and a number is important here. Moreover it could be done transparently to all (ok, most) of available software.

Windows is equipped with “fsutil” tool to covert this feature. However ranges of the potentially empty regions with zeros have to be specified manually. And before the the actual sparse range is set file has to be marked as a sparse file with the following command:
 fsutil sparse setflag <file_name>

Next, actual sparse regions can be set. For example:
fsutil sparse setrange C:\Temp\sample.txt 65536 131072

Finally the the list of sparse ranges can be obtained :
fsutil sparse queryrange C:\Temp\sample.txt

To check if the file is in fact sparse file the following command has to be executed:
fsutil sparse queryflag C:\Temp\sample.txt

That is it, as for an interface that is being provided out of the box and is present in every Windows instance. In the next snippet I will provide more sophisticated mechanism of “sparse files” management.

Related links:

Is This A Good Question/Topic? 0
  • +

Page 1 of 1