In the newest release of FSLogix (FSLogix Release Notes – FSLogix | Microsoft Learn) a new VHDX compaction feature is enabled by default. As most of you probably know, VHDX files dynamically grow but don’t dynamically shrink on their own. For example, if you download a 5GB ISO file to your FSLogix profile desktop, your VHDX file grows by 5GB. When you delete that file, the VHDX remains the same size and does not automatically shrink. Traditionally, it was a manual (or scheduled automation) task to occasionally shrink your users’ VHDX profiles. With the new VHDX Compaction feature, a formula is used to determine whether a profile is large enough and has enough empty space (unused space within the VHDX file) to be compacted. Every time a user signs out, their VHDX is evaluated. If it passes the rules for compaction, then compaction occurs at sign-out and the “Waiting for FSLogix Apps Services” will show on their session desktop during the process. The formula summary is below, but complete details can be found here.
- Dynamic hard disks must be used. Compaction won’t occur for Fixed vhdx disks.
- The VHDX file must be at least 1 GB
- The VHDX must be shrinkable by at least 20%. For Example, if you have a 5GB VHDX file, at least 1GB needs to be compactable white space. (5 * 0.2 = 1).
One important thing to remember – this feature relies on the “defragsvc” service. If that service is set to disabled, then compaction will not happen. Make sure this service is set to Manual or Automatic on your AVD session hosts:
Remember, this feature is enabled by default. So, once you install this FSLogix version, compaction will start happening when users sign out. In the event you want to disable compaction, you’ll need to add a registry value on your session hosts. You can find details here – Disable VHD Disk Compaction – FSLogix | Microsoft Learn.
The registry value for this feature is HKLM:\Software\FSLogix\Apps\VHDCompactDisk. A Value of 1 is enabled, and a value of 0 disables this feature. You’ll notice this registry value does not exist after updating to this FSLogix version, but compaction will still occur since it’s the default behavior. We can see in our FSLogix profile log (C:\ProgramData\FSLogix\Logs\Profile) that without that registry value, it uses the default of “1”, which is enabled. In the event you want to disable this feature across numerous hosts, you can use Group Policy and set the property under Computer Configuration > Policies > Administrative Templates > Disk Compaction.
After some users have signed in and out of your AVD environment, you can verify if their profile was compacted using the FSLogix logs or the event viewer. Let’s look at the FSLogix log first. An easy way to find the log entries is searching for “WasCompacted: True” or “WasCompacted: False”. This shows some additional details on the size of the disk, the space saved, and how long compaction took. If you have never ran compaction on your profiles before, users will likely see a long sign-out the first time after this FSLogix version is installed. The compaction process takes some time and depending on size of VHDX and may take a couple minutes.
Additionally, we can search the Applications and services event log on our AVD hosts under Microsoft > FSLogix > Apps > Operational. Filter by eventID 57, which contains the disk compaction log entries. Two examples below show an entry where compaction occurred, and another where it did not since the disk did not fit the requirements for compaction:
That’s about it. Aside from verifying defragsvc service is not disabled, there’s no additional work to configure this and you no longer have to worry about manually compacting your VHDX profiles.
Microsoft Resources with additional details: