Automated Linux VMs on Hyper-V 2012

Solution 1:

Windows can't mount an ext3/4 file system natively and most of the software packages out there to do so are (in my opinion) untrustworthy. So that is out.

A couple of ideas to get you started:

  • Set up a Linux VM that runs all the time for the purpose of configuring new VMs. When you create a customer VM, attach the VHDX to this configuration VM. Write a web service that performs the customization you need. You can be sure you are customizing the correct VHDX by mounting the partition using The SCSI ID, which you will know because PowerShell will tell you what ID was assigned when you attached the VHDX.
  • Initially boot the VM via PXE. The boot image can do the customization you need and then shut down the VM, which would be the signal to your PowerShell script to change the boot order to hard drive first and start the VM. If you go this route, I suggest creating a dedicated VLAN for the PXE customization for security reasons.
  • Create a FAT partition in your image that you can mount within Windows and copy your configuration file to it. Your Linux image should either be configured to look for the kick start file in that location or contain a script to copy it to the correct location during startup.