One of Windows's most recently introduced features is SMB compression. This can reduce the amount of data transferred between the client and the server. Compression may now be activated for file shares or mappings, and is managed via Windows Admin Center or PowerShell.

The first prerelease of SMB compression was limited to the robocopy and xcopy utilities, which received their own parameters for this purpose. This will now change in Windows 11 and the final version of Server 2022. They allow you to configure file shares or drive mapping so that compression works independently of these utilities. The feature is compatible with SMB signing and encryption, SMB over QUIC, and SMB multichannel. However, it cannot be used together with SMB Direct.

Biggest impact on slow networks ^

SMB compression is especially beneficial when transferring very large files over slow networks. Saving Office documents on a LAN file share will therefore not benefit much from this. First, most files are too small, and additionally, DOCX and PPTX files are already compressed.

Because of this, Microsoft originally used an algorithm by default that initially compressed the first 500 MiB of very large files and only continued if at least 100 MiB of it could be significantly reduced. It was intended to prevent wasting computing power with little to no reduction in the amount of data.

However, after releasing Server 2022, Microsoft changed its mind and disabled this behavior. Therefore, when compression is requested, it affects all files.

Adjusting SMB compression behavior ^

If you dislike this new default behavior of SMB compression, you can use two entries in the registry under HKEY_LOCAL_MACHINE > System > CurrentControlSet > Services > LanManWorkstation > parameters to change it.

NameValueType
CompressibilitySamplingSize524288000REG_DWORD
CompressibleThreshold104857600REG_DWORD

CompressibilitySamplingSize obviously stands for the size of the block that is compressed on test for large files. The value 52488000 in our example corresponds to 500 MB and thus activates the original behavior.

CompressibleThreshold specifies the size below which files should be ignored. 104857600 corresponds to 100 MB. The new setting takes effect immediately; a restart is not required.

Enabling compression on the server ^

Microsoft provides either Windows Admin Center (WAC) or PowerShell to enable SMB compression.

If you prefer the GUI, then go to Files and File Sharing in the WAC, and from there to the File Shares tab. As you create a new share or edit an existing one, you will find the checkbox Compress data in the corresponding form.

Option to enable SMB compression for a specific share

Option to enable SMB compression for a specific share

Older versions of Windows Server will have this option disabled, as compression is not supported there.

If your device is running Windows Server 2019 then SMB compression is not supported

If your device is running Windows Server 2019 then SMB compression is not supported

If you use PowerShell for this task, proceed this way when setting up a new file share:

New-SmbShare -Description "Compression-Test" -Path C:\Users\Public\Documents\ `
-CompressData $true -Name "Docs"

The New-SmbShare cmdlet has a new parameter named CompressData on Windows 11 and Server 2022, which has not yet been documented by Microsoft.

Enable SMB compression when creating a new share with PowerShell

Enable SMB compression when creating a new share with PowerShell

To enable compression for an existing share, use the following command:

Set-SmbShare -Name "Compression-Test" -CompressData $true

If you want to get an overview of the shares on which compression is active, the standard output of Get-SmbShare does not show this. To display this data, the following command will help:

Get-SmbShare | select Name, Path, Description, CompressData

To show all shares with compression enabled, the easiest way is to launch this command:

Get-SmbShare -CompressData $true

Enable compression on the client ^

The described methods enable SMB compression on the server, which can also be Windows 11 if the workstation shares a directory. Compression can also be enabled from the client side. The following command is used to request SMB compression for a new drive mapping:

New-SmbMapping -LocalPath "J:" -RemotePath "\\server.contoso.com\share" `
-CompressNetworkTraffic $true

As you can see here, the name of the parameter CompressNetworkTraffic is not consistent with the other two cmdlets. In addition, the question arises as to whether the client can only successfully request compression if the feature is also enabled on the server. Microsoft's documentation does not provide any information on this.

Disable compression ^

If you want to prevent the SMB client from requesting SMB compression in general, the following command accomplishes this task:

Set-SmbClientConfiguration -DisableCompression $true

As expected, $false does the opposite, namely, that it will always request compression.

There is no counterpart for the server; the registry has to be edited for this purpose:

Subscribe to 4sysops newsletter!

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters]
"DisableCompression"=dword:00000001
Compression cannot be enforced this way; the assignment of "0" does not achieve this.
+2
avatar
1 Comment
  1. Leif Davisson 3 weeks ago

    Make sure your backups support compression.

    0

Leave a reply

Please enclose code in pre tags

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2021

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account