Windows 7 – Removing `sparse` file attribute

What’s the sparse file attribute on NTFS partitions and how can one remove it?

Using Windows 7, Windows 8 and Windows 8.1.

Solution:

Nicole Hamilton provided the description of what sparse files are.
Let’s learn it with an experiment.

Creating a Sparse File

Start a Command Prompt (cmd.exe) as Administrator.

  1. Creating large file:

    fsutil file createnew test.nul 1048576
  2. Check its size in Explorer:
    • Size: 1.00 MB (1,048,576 bytes)
    • Size on disk: 1.00 MB (1,048,576 bytes)
  3. Let’s mark it sparse:

    fsutil sparse setflag test.nul
  4. Nothing changed so far, the both sizes are still 1.00 MB.
  5. Let’s mark the entire byte range as sparse:

    fsutil sparse setrange test.nul 0 1048576
  6. Now the sizes changed dramatically:
    • Size: 1.00 MB (1,048,576 bytes)
    • Size on disk: 1.00 KB (1 024 bytes)
  7. You can query if the file is sparse or not with fsutil:

    fsutil sparse queryflag test.nulThis file is set as sparse

    Or

    This file is NOT set as sparse

The value of Size on disk depends on the cluster size of the file system. The default cluster size on NTFS is 4 KB. The drive I used for testing was formatted with 1 KB cluster.

I used this article as the source.


Removing Sparse Attribute

The utility I used in the example does not provide a flag to remove sparse attribute.

The simplest way to do is to copy the file. The file will lose this special attribute if the application that copies it does not specially preserve the sparse attribute and sparse range.

You can use Far Manager to clear the sparse attribute. Navigate to the file and press Ctrl + A to open Attribute dialog. Clear Sparse check box. And click Set button.Attributes of test.nul file in Fra Manager