When to use SMB WriteThrough in Windows Server 2019

Today, we are going to discuss the Server Message Block (SMB) protocol which is incorporated into all Windows versions, both client and server. It is enabled by default and used to share files and printers. There are rather few versions of this protocol, but it was SMB 2.0, released with Windows Vista in 2006, that considerably improved its performance. Today, the latest version is SMB 3.1.1, that was released with Windows 10 and Windows Server 2016.

The focus of this version was on security by adding support for more encryption algorithms, leaving the performance practically unchanged. And although we don’t get the new protocol version with Windows Server 2019, there is one novelty added to the SMB protocol that affects the client side.

SMB cache

With the release of Windows Server 2019 (also available in Windows 10 version 1809), SMB connections on the client side now can be used without the SMB cache. In certain scenarios, this will accelerate the transfer of files sent using this protocol.

Here’s how you find this new parameter:

Let’s see how it works and when it’s a good idea to use it.

SMB operation without the WriteThrough/UseWriteThrough parameters

By default, when Windows SMB client makes a connection to an SMB server, the client uses the SMB cache. We have to understand that this SMB client can be a Windows Server.

SMB client is a computer that makes the connection to a shared resource and SMB server is a computer that has that shared resource. The SMB cache is very useful in most cases. For example, imagine a user accessing their files on a file server. When he opens a file for the first time the SMB client downloads it completely but saves it in cache. When the user makes a modification to the file and saves the file, the file is not downloaded again, the load is faster since the file is in the cache. That is the default behaviour of the SMB cache for the SMB client and works in every Windows SMB version.

What is the WriteThrough parameter for?

This parameter allows to map a network unit with forced access (“direct write”) and thus omit all the operating system caches, forcing the read/write to disk.

Previously, “direct writing” was only possible in the shared resources of the cluster with the option marked “Continuous Availability.” In addition, version 3 of the SMB protocol and at least Windows Server 2012 were required. But with Windows Server 2019 and Windows 10 v.1809 you can now force the “direct write” from the client side.

Tip: To quickly check the version of your Windows Server (or Windows 10), run the winver command in either cmd or PowerShell.

When to use it?

This option can be used when we know for sure that the file that we’re going to write doesn’t exist at the destination yet and is of a considerable size. For example, it’ll be much faster for a backup software to write a backup file via SMB connection with “WriteThrough” parameter, avoiding the operating system’s cache.

How to enable the SMB WriteThrough connection

As previously noted, SMB connections are made from the SMB client, so to enable this, we would need to do the following.

WriteThrough with CMD

Execute the Net Use command to see the new WRITETHROUGH parameter:

Net Use \\Server\share /WriteThrough

If you want to assign a drive letter, execute:

Net Use (Drive letter): \\Server\share /WriteThrough

Connection example:

– Destination SMB Server: SYSADMIT-PC1

– Destination SMB Shared folder: SYSADMIT-Share

– Network unit: None

Example command would look like:

Net Use \\SYSADMIT-PC1\SYSADMIT-Share /WRITETHROUGH

WriteThrough with PowerShell

The equivalent to the Net Use command in PowerShell is the New-SmbMapping cmdlet. It also allows us to make SMB connections without caching using the UseWriteThrough parameter.

Example:

– Destination SMB Server: SYSADMIT-PC1

– Destination SMB Shared folder: SYSADMIT-Share

– Network unit: S:

Example command would look like:

New-SmbMapping -LocalPath ‘S:’ -RemotePath ‘\\SYSADMIT-PC1\SYSADMIT-Share’ -UseWriteThrough $True

Conclusion

As you see, it’s pretty easy to utilize the WriteThrough ability with a few short commands. What’s important is to understand when it’s a good idea to use it since in most cases using the cache is fine. But in certain scenarios like creating new large files at the destination, we would benefit going around the SMB’s cache.

See More:

Exit mobile version