大网数据广告活动
服务器运维问答

How to inject a file into a Linux VM running on Hyper-V?

· 52CE 我爱测

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 ext…

问题原文

原帖链接 · Bilbo Bongo · CC BY-SA 4.0

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?

已采纳解答

原帖链接 · ravikanth · CC BY-SA 4.0

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 cmdlet.

Copy-VMFile -Name centos001n -SourcePath 'C:\Scripts\myPytonLib.tar' -DestinationPath '/home/ravi/scripts' -FileSource Host

There are, of course, other methods if you have network connectivity.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-06-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。