Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save skyhoshi/dab7d6d3812428dbf5bb652c6c00b965 to your computer and use it in GitHub Desktop.
Save skyhoshi/dab7d6d3812428dbf5bb652c6c00b965 to your computer and use it in GitHub Desktop.
This is a Gist to describe the VHDX Install folder project
Public: Github Project.
https://github.com/skyhoshi/VHDXToFolders
## Story
Project Story: (Use Case/ User Story/ My Experience)
History of the Project:
This project was one of necessity. After 20+ years of collecting, developing and loosing/misplacing projects and source files, When Windows 7 ( + Windows Server 2008) presented the ability to create Virtual Machines. Virtual Hard drives became a standard in storing a lot of “Shared” data. I had virtual hard drives that I would attach and detach from virtual machines to do maintenance and installations.
A few years ago with the introduction of Windows 10, Hyper-V and Hyper-V PowerShell Module I was able to script out the creation of Virtual Hard Drives and took the concept of sharing one step further by attaching these drives to folders (Folder Mounting).
Theories and Practice:
With this I could in theory, install games onto to my SSD drive but when I wasn’t playing the game but needed additional space on the then limited space of my SSD I could dismount and displace the VHD to a Cold storage Spindle based drive (lesser performing drive) or even push the drive up to network storage for archiving.
I took the theory one step further when I started working for GiftCertificates.com and used the virtual hard drive storage process to section of projects and configurations in order to better my development performance and time spent between different projects all while managing the space, and what was presented to me at any given time in the work environment.
Passing on the concept:
I’ve taken my time to convert the large group of scripts and methods down to a concise and simple PowerShell Module that will allow you to take a given folder on your system with a virtual hard drive that is mounted to the folder but is stored separately.
Currently the project is unfinished, but the base scripts needed to mount existing virtual hard drives at startup are present. The generation methods for creating the mounting config files and scripts are in the source but the automation of converting a given folder to a virtual hard drive backed storage folder is rather scattered and currently not included in the source due to liability reasons. (an issue that I ran into is corruption and deletion of files during moves, until I can ensure that this does not happen / cannot happen within my scripts I’ve left these out. I, myself am required to manually move important folders due to the scripts tenuous nature.)
## Project Information
Project Outline:
1. Create the VHDX (Command Line, Disk Management(prefered way))
a. Size Does matter but not until you run out of it on your storage drive
b. One VHDX file to One VHDX folder (Current configuration, May be possible to associate multiple volumes on a singe VHDX file to multiple folders but that’s out of scope for this concept)
2. Use Scripts (Disk Part, PowerShell Mount-Vhd) to automate mounting of one or many drives at system startup, logon, and other times)
a. The prefered way is installing the latest version of powershell and running the script via a task scheduled task. {Attempt the following command: "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Tools-All" }
b. Disk Part can be used as a replacement for the Mount-VHD if the computer cannot install the required Microsoft-Hyper-V-Management-PowerShell module. (it's requirements are not clear but I've had issues with having the proper requirements installed on a windows 10 Pro system in the past.
3. Manage, backup, maintain system disks if you choose to update/upgrade or uninstall an application.
a. Update: in some cases after an update it would be highly adviseable to run Optimize-VHD
4. Remove Hypver-V Dependancy
a. On Windows 10 this may be possible but it means writing new Create and Mount Scritps for the VHD. it also may mean reaching back to the DiskPart Dependancy used prior to Hyper-V
5. What is a VHD Set
a. Should I use a VHD Set / snapshot with these installs? [Create VHDX Sets](https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/manage/create-vhdset-file)
6. How to fix a broken mounted vhd (if the system doesn't know how or where to mount the vhd)
Using Disk Manager to Create, Maintain and Monitor VHD Mounts.
## Steps in the process
1. Analyze storage for your new VHDX drive.
* Ensure Drive has enough space for the contents you wish to "Displace"
* Keep File Closest to Root of secondary drive as possible. (this prvents problems with VHDX File assingments to folders and chaining problems should you have "VHDX Inception"(VHDX inside VHDX Inside VHDX))
1. Create the VHDX, if you use Fixed Size you will have the space consumed at the time of the drive creation, it's recommended you use dynamically expanding.
1. Initialize the VHDX, Creating the partition and Volume on the disk. IMPORTANT: If your assigning this folder as a FOLDER Junction (assigning it to be a folder mount point) you must not assign a drive letter, or if one is assigned remove it.
1. Ensure the folder you intend to mount the drive to exists AND is empty.
* in the script I add a Dash (-) to the existing folder and then recreate the empty folder again to ensure any existing data can be move OR the process can easily be undone should the process fail at any point.
1. Mount the Drive to the Folder.
1. Install or COPY (see note below) you application
* IMPORTANT: !!COPY!! the data to the new folder. (this will take time as the data is copying across drives[depending on where you saved your vhdx])
* Install the application as normal
* VALIDATION: You will see data being writting to the VHDX and the drive space start to grow on the secondary hard drive.
1. Test the application by attempting to run it.
1. Add the location of the VHDX to the Mount Script (DiskPart Script or PowerShell Scirpt)
1. Restart the computer to test the Mount Script.
## Videos - Outlines (Not Created, Ideas for Videos)
Comming in Nov 2020: These Videos will be posted on the readme of the source git.
1. Demonstrate Creation and deployment to a folder via Gui
1. Disk Management - Microsoft Management Console
1. VHD vs VHDX (what's the difference)
1. Where To Store
1. Fixed vs Dynamically Expanding
1. Create VHDX - Size Specification
1. Is My VHD(x) Too Large?
1. How Many VHDX Drives can I mount?
1. Demonstrate Creation and deployment to a folder via Powershell scripts in git
1. Explain "VHD Inception" (VHD stored within VHD)
1. Explain Symbolic Links and Junctioning
@skyhoshi
Copy link
Author

added step by step process for new install/existing install of Application on windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment