Tuesday 21 April 2020

FSLogix profile compacting

I've done a lot of work with Windows Virtual Desktop recently and I've incorporated profile management with FSLogix technology. It all works really well and users can log in to the desktop really quickly, even with large profiles. Remember roaming profiles. I hated those. You can read about my experience configuring FSLogix containers here

FSlogix containers use VHD or VHDX files. This has one drawback in that these files do not shrink on their own and the file sizes can be bigger than they need to be. This could be a problem in your infrastructure as you have to pay for the storage.

Let's have a look at the file sizes in my test lab.



This is the FSLogix VHD associated with my profile. It's pretty big at almost 12GB. 


But is the profile really that big? You can mount the VHD to look inside.


You'll get an error that the file could not be mounted. No problem, we just have to give it a drive letter.


Open Disk Management and you'll see a new disk for the profile. 


Right click the disk and choose Change Drive Letter and Paths.


Choose a drive letter and select Add.


The disk is now ready......


…..and you'll see that the drive is now mounted.


You can now see the real profile size. See my profile is 1.6GB. That's a lot smaller than the VHD of 11.8GB.


Don't forget to eject the drive. We don't want to leave it mounted when not in use.


This is the overall size of the VHDs in my test lab. It's 56GB which is a lot bigger than it needs to be. 

Luckily there are community scripts available that can help with this problem.

You'll find a good one here. The FSLogix Profile Compacting tool was written by David Ott (@citrixirc). These are David's instructions:


  1. The program will remember the last directory selected (via an .ini file – if it exists), or you can click the “…” button at the top left to browse to the root directory of your profile share.
  2. Once a directory is selected it will list all .vhd and .vhdx files along with their current size and their current locked status in descending order by size.
  3. Select the profile(s) you wish to compact (you can select multiple using ctrl and shift+click)
  4. Click the compact button, and the program will process each profile selected one at a time
    1. Checks one more time to make sure the file is not locked
      1. If it is, it will skip on to the next one
    2. Gets the current size again before processing
    3. Attaches the vhd(x) in R/W mode
    4. Finds the first available drive letter it can assign (between D and Z)
    5. Waits 3 seconds before assigning the drive letter (there can be a timing issue if you don’t wait a couple of seconds between mount and drive letter assignment)
    6. Defrags the mounted volume
    7. Detaches and re-attaches as read only
    8. Uses diskpart to compact the vhd(x)
    9. Gets the size of the file post processing
    10. Updates the results pane
  5. After it has run through all the selected profiles it will display the total reduction in MB at the bottom.
So let's see the tool in action.


I've download the tool to the server containing the FSLogix profiles. It's an executable file. Launch the tool.


Browse to the folder containing the VHDs. They will be listed showing the name, size and status (locked or not). Containers that are locked are in use and cannot be compacted.


Select the profiles and choose Compact.


In Disk Management you will see each VHD being mounted in turn (if you care to).


You can track progress in the tool.


The process has finished and the VHDs have been compacted. See some have not been touched as they were in use.


Let's see what it did to my profile. There has been a massive compaction. It is now 1.7GB (remember it was 11.8GB).



My overall profile size has been reduced from 58.6GB to 44.1GB in 10 minutes. That is certainly worth doing. It would be a good idea to implement this a regular scheduled task. Remember though that you'll never get the same reduction again as you did the first time.

I hope this helps. Until next time...….

No comments:

Post a Comment