How to check whether my NTFS volume is compression?

I want to check whether my NTFS volume is compression?
I use GetVolumeInformation(), it can’t work to show FS_VOL_IS_COMPRESSED.
I use DeviceIoControl() with FSCTL_GET_COMPRESSION, it only works on file or
directory.

Which function should I use? Thanks.

Have you checked to see if GetVolumeInformation returns FS_FILE_COMPRESSION?
A quick test shows that if you check the “compress drive to save disk space”
box in a NTFS volume’s properties dialog, a subsequent call to GVI will
return FS_FILE_COMPRESSION and not FS_VOL_IS_COMPRESSED. It’s a bit
misleading – the property UI would lead you to believe that the compression
is done at the volume level, but it’s actually done at the file level (as
you might surmise when you’re asked whether or not to apply compression only
to the root or to all directories or files).

It’s my impression based on a quick read of the API doc that
FS_FILE_COMPRESSION is intended for FAT-based compression schemes such as
DoubleSpace. AFAIK, nothing like that exists for NTFS.

Note that FS_VOL_IS_COMPRESSED and FS_FILE_COMPRESSION are mutually
exclusive; at most one of those flag bits will be set. So something like
this should work:

GetVolumeInformation(…, &dwFlags, …);
if (dwFlags & (FS_VOL_IS_COMPRESSED | FS_FILE_COMPRESSION))
bCompressed = TRUE;
else
bCompressed = FALSE;

“Sun Jiajie” wrote in message news:xxxxx@ntfsd…
>I want to check whether my NTFS volume is compression?
> I use GetVolumeInformation(), it can’t work to show FS_VOL_IS_COMPRESSED.
> I use DeviceIoControl() with FSCTL_GET_COMPRESSION, it only works on file
> or directory.
>
> Which function should I use? Thanks.
>
>

In NTFS, volumes cannot be compressed, only individual files and
directories.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Sun Jiajie”
Newsgroups: ntfsd
To: “Windows File Systems Devs Interest List”
Sent: Monday, August 28, 2006 1:38 PM
Subject: [ntfsd] How to check whether my NTFS volume is compression?

> I want to check whether my NTFS volume is compression?
> I use GetVolumeInformation(), it can’t work to show FS_VOL_IS_COMPRESSED.
> I use DeviceIoControl() with FSCTL_GET_COMPRESSION, it only works on file or
> directory.
>
> Which function should I use? Thanks.
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

When formatting an NTFS volume, the compression attribute can be set. True,
it only applies to files, but all that volume will have the files
compressed. I have used it, but it doesn’t do much besides slow you down if
it is compressed files such as zips, mpegs, etc.

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntfsd…
> In NTFS, volumes cannot be compressed, only individual files and
> directories.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: “Sun Jiajie”
> Newsgroups: ntfsd
> To: “Windows File Systems Devs Interest List”
> Sent: Monday, August 28, 2006 1:38 PM
> Subject: [ntfsd] How to check whether my NTFS volume is compression?
>
>
>> I want to check whether my NTFS volume is compression?
>> I use GetVolumeInformation(), it can’t work to show FS_VOL_IS_COMPRESSED.
>> I use DeviceIoControl() with FSCTL_GET_COMPRESSION, it only works on file
>> or
>> directory.
>>
>> Which function should I use? Thanks.
>>
>>
>>
>> —
>> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>>
>> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>

> When formatting an NTFS volume, the compression attribute can be set. True,

it only applies to files, but all that volume will have the files
compressed. I have used it, but it doesn’t do much besides slow you down if
it is compressed files such as zips, mpegs, etc.

Thanks for correcting me. More exactly:

  • in NTFS, only file contents are compressed, not the metadata.
  • the “compressed” attribute on the directory means - any new files created in
    it will be compressed.
  • the “compressed” attribute on the volume (set at format time) means - root
    directory is compressed.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com