- New Group Policy settings in Windows 11 23H2 - Mon, Nov 20 2023
- Windows Server 2025 will support SMB over QUIC in all editions - Fri, Nov 17 2023
- Switch between Windows Terminal and the legacy console - Thu, Nov 16 2023
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.
Name | Value | Type |
CompressibilitySamplingSize | 524288000 | REG_DWORD |
CompressibleThreshold | 104857600 | REG_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.
Older versions of Windows Server will have this option disabled, as compression is not supported there.
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.
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.
Read the latest IT news and community updates!
Join our IT community and read articles without ads!
Do you want to write for 4sysops? We are looking for new authors.
Make sure your backups support compression.