Sample Use Case
For this sample use case, you have an organization with 1000 users. Typically, the staff logs off around 5 PM on Friday night and starts logging back in to the system at 8 AM on Monday morning. This gives you 63 hours of downtime to optimize user disks. However, using all of the downtime is not recommended. The best practice is to place a buffer of time on the front and backend of the compaction process. If you start the compaction process at 10 PM on Friday and stop it at 3 AM Sunday, you have 53 hours to complete compacting as many VHDs as possible.
In general, compacting a VHD averages 3-5 minutes per disk, or 12-20 VHDs per hour. The first run takes the longest, but each session should get faster as more compactions are done. With our use case of ~20 VHDs per hour * 53 hours, you should be able to compact ~1060 VHDs. Based on the amount of VHDs to complete in the given time period, it is highly likely that not all will finish. Some will have to be done in the next compaction session.
CompactVHD Workflow
Here is the main workflow for the compacting tool.
- CompactVHD looks for existing ProfileUnity or Microsoft FSLogix multi-session child disks.
- If a child disk exists, then the parent disk is NOT current and this disk will be skipped. The child disk needs to be committed or deleted before compacting the parent disk.
- The tool will check to make sure the VHDX to be compacted is not locked.
- If the disk is locked, it is likely that a user is logged in, a disconnected session has the disk open, or the file server is holding an open handle on the disk. CompactVHD will skip performing optimization on these disks.
- The parent disk is copied to the local temp path.
- It is best to perform the optimization locally. The free disk space needed locally in %temp% is equal to your largest disk. If the largest disk in your user population is 20 GB, then you will need 20 GB free locally.
- Optimization steps are performed.
- The newly optimized disk is copied back to the source disk path with a temporary name.
- CompactVHD verifies the original disk has not been modified.
- For example: If a user were to log in while the tool was performing its optimization steps, then the work would be discarded at the end of the compacting process. The version of the disk that was optimized is no longer the most current version.
- The original virtual disk filename is appended with
.BKand the newly optimized disk is put into place.- This process takes milliseconds and is the best chance that a user will not log in during the swap of the two disks making the new disk the primary disk.
- The original disk is never mounted, just renamed, if all the steps are 100% successful. This avoids locked production disks at the start of the next shift. Worse case, the copied disk could be locked if something happens in the middle of the process (for example, if Windows Updates reboots the host we are running on).
Sample Command Line Usage
The following is a sample command with options that can be used to compact the VHDs.
LwL.ProfileUnity.Client.CompactVHD.exe /VHDDir \\server.local\home /MinDaysSinceLastCompaction 30 /BackupPath \\bk.local\bkUserProfileDisks /MinDiskMB 1024 /MaxHours 53 /SMTPServer smtp.server.local /MailTo IT@local.com /MailFrom ProU_Compact@local.com /AcceptEULA
Command Line Summary
Looking at the command line usage options selected above, the following is a summary of intended actions to perform.
The tool will compact ALL VHDX files it finds in all sub directories in \\server.local\home. Any VHDs that were already compacted in the last 30 days will be skipped. Note any VHDX that is the same size after compaction as it was before compaction will be aborted. The backup location of the original disks will be stored in another network path (\\bk.local\bkUserProfileDisks) and not in the production share for the user’s disks. Any VHDX that is not at least 1024 MB in size will be skipped. The maximum hours the job will be allowed to run is 53 hours, and it will gracefully finish its last job if it was started right before the 53-hour mark. An email report of Nominal, OrigSize, NewSie, Savings, MM:SS and File Name (all sizes in MB) will be sent to IT@local.com from ProU_Compact@local.com using mail server smtp.server.local. The final step is the acceptance the End User License Agreement to authorize the use of the tool. The parameter of /AcceptEULA is required in all options for the tool to perform its function.
