I borrowed much (most) from Johan Arwidmark over at deploymentresearch.com: http://deploymentresearch.com/Research/Post/406/Beyond-Zip-How-to-store-183-GB-of-VMs-in-a-16-GB-file-using-PowerShell and Teh Wei King's System Center Blog: https://weikingteh.wordpress.com/2013/01/15/how-to-enable-data-deduplication-in-windows-8/
Here's a brief outline of what I'll cover here:
- Create VHDX file, mount it to a drive letter, copy files.
- Enable Dedup on Windows 8.1.
- Dedup the VHDX volume.
- Create symlinks to the new location.
- Automatically mount VHDX files on boot.
It should be immediately pointed out that de-dup is not officially supported in Windows 8.1, however, when it works, it's really dang awesome! Additionally, symlinking is really not necessary at all, but it is really nice if you don't want to re-install applications, re-link paths to VHDXs, etc.
- Create VHDX file, mount it to a drive letter, copy files. Create the VHDX file using Create-VHDX.ps1. It will automatically mount the VHDX to a drive letter. After mounted, copy your VMs, files, apps, etc. to the new drive.
- Enable Dedup on Windows 8.1. First, grab the CAB files to enable the features in Windows 8.1. Make sure you copy the CAB files to the directory that you plan on running Enable-Win81Dedup.ps1 from or you'll need to specify the full paths to the CABs.
- Dedup the VHDX volume using Dedup-VHDX.ps1. You can check to see how we did by running a Get-DedupStatus command.
- Create symlinks by specifying the link and target directories with New-SymbolicLink.ps1.
- Automatically mount VHDX files on boot. There are at least a few ways to mount the VHDX on boot, however I found it difficult to consistently get the same drive letter, which was important since I wanted to create symlinks, so I chose to implement using a scheduled task and diskpart. You can create the scheduled task to mount the vhdx on boot by running Map-VhdxOnBoot.ps1.
Okay that's it! We're done! I hope you found this to be an useful exercise in how these somewhat unrelated capabilities can be paired together in an interesting way.
You can grab all of the scripts referenced in this article from here: http://1drv.ms/1zRejwj and the CAB files for enabling the dedup features can be found here: http://1drv.ms/1zReszA