How to inject a file into a Linux VM running on Hyper-V? – A server stack is the collection of software that forms the operational infrastructure on a given machine. In a computing context, a stack is an ordered pile. A server stack is one type of solution stack — an ordered selection of software that makes it possible to complete a particular task. Like in this post about How to inject a file into a Linux VM running on Hyper-V? was one problem in server stack that need for a solution. Below are some tips in manage your linux server when you find problem about linux, powershell, hyper-v, ext4, vhd.
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?
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 the
Copy-VMFile -Name centos001n -SourcePath 'C:ScriptsmyPytonLib.tar' -DestinationPath '/home/ravi/scripts' -FileSource Host
There are, of course, other methods if you have network connectivity.