I am trying to create a CentOS image template and my environment requires me to add a route file to the networking which would be different on each deployment.
Is there any way for me to inject a file from a Hyper-V host to a ext4 formatted Linux guest VHD?
Ideally I'd like to be able to write to script the creation of a VM in Powershell by copying the template VHD and injecting the route file to the VHD.
Is this possible?
Best Answer
There are multiple ways to perform this.
If you have Linux Integration Services (LIS) installed, you can use the
Copy-VMFile
Cmdlet on the Hyper-V host where the VM is running to copy the files into the Linux VM. On the VM settings, you need to enable Guest Services.Once you have the LIS installed in Linux guest and Guest Services enabled in VM settings, ensure that the
hypervfcopyd
is running inside the guest. You can, then, use theCopy-VMFile
cmdlet.There are, of course, other methods if you have network connectivity.