设计与多媒体

Hyperv Create Vm

试用

Create Ubuntu 24.04 VMs on Windows Hyper-V from cloud images with cloud-init. Handles all the gotchas: sparse VHDX fix, hv_netvsc network config, permissions...

它能做什么

Create Ubuntu 24.04 VMs on Windows Hyper-V from cloud images with cloud-init. Returns a Docker-ready VM with SSH access.

技能文档

Hyper-V VM Creator

Create Ubuntu 24.04 VMs on Windows Hyper-V from cloud images with cloud-init. Returns a Docker-ready VM with SSH access.

When to Use

  • "create hyper-v vm"
  • "spin up vm on hyper-v"
  • "new hyper-v ubuntu vm"
  • Any time you need a fresh Linux VM on a Windows Hyper-V host

This is a base skill. It creates the VM. Other skills (soc-deploy-thehive, soc-deploy-misp) deploy applications onto it.

User Inputs

ParameterDefaultRequired
VM name-Yes
Hyper-V hosthyperv-host (YOUR_HYPERV_IP)No
CPU cores2No
RAM4GBNo
Disk40GBNo
VM user password(generated)No
Extra cloud-init packages-No
Network switchDNS-NIC-SwitchNo

Prerequisites Check

# SSH to Hyper-V host
ssh hyperv-host "echo OK" 2>/dev/null || echo "FAIL: Cannot SSH to Hyper-V host"

# qemu-img on Windows
ssh hyperv-host 'where "C:\Program Files\qemu\qemu-img.exe"' 2>/dev/null || echo "FAIL: qemu-img not installed (choco install qemu -y)"

# genisoimage on Linux (for building cloud-init ISO)
which genisoimage || echo "FAIL: genisoimage not installed (apt install genisoimage)"

Execution Flow

Step 1: Build cloud-init ISO (on Linux)

# Password via env var (recommended, avoids shell history/process list exposure)
VM_PASSWORD="" bash scripts/build-cidata-iso.sh  [ssh-public-key]

# Or via stdin
echo "" | bash scripts/build-cidata-iso.sh  [ssh-public-key]

# Creates /tmp/-cidata.iso

The ISO contains three files:

  • user-data: deploy user, Docker, Compose v2, SSH password auth
  • meta-data: instance-id and hostname
  • network-config: hv_netvsc DHCP match (CRITICAL for Hyper-V networking)

Step 2: Transfer files to Hyper-V host

# Cloud image (if not already cached)
wget -q https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img -O /tmp/ubuntu-24.04-cloud.img
scp /tmp/ubuntu-24.04-cloud.img hyperv-host:C:/Users/youruser/Downloads/

# Cloud-init ISO
scp /tmp/-cidata.iso hyperv-host:C:/Users/youruser/Downloads/

Step 3: Create VM (elevated PowerShell on Hyper-V host)

# Copy script to host
scp scripts/create-vm.ps1 hyperv-host:C:/Users/youruser/Downloads/

# Execute (needs elevation)
ssh hyperv-host "powershell -ExecutionPolicy Bypass -File C:\\Users\\youruser\\Downloads\\create-vm.ps1 \
  -VMName  \
  -CloudInitISO C:\\Users\\youruser\\Downloads\\-cidata.iso \
  -DiskSizeGB  -MemoryGB  -CPUCount "

Step 4: Wait for boot and find IP

sleep 90  # Cloud-init needs ~90 seconds

# Hyper-V VMs have MACs starting with 00-15-5d
arp -a | grep "00-15-5d"

# Get VM MAC to match
ssh hyperv-host "powershell (Get-VMNetworkAdapter -VMName '').MacAddress"
# PowerShell shows: 00155D38010A
# ARP shows:        00-15-5d-38-01-0a

Step 5: Verify SSH and Docker

ssh deploy@ "docker --version && docker compose version && echo 'VM READY'"

Return Values

Report to caller:

VM Created: 
IP: 
SSH: deploy@ (password: )
Docker: installed
Docker Compose v2: installed

Teardown

To destroy a VM completely:

ssh hyperv-host "powershell -Command \"Stop-VM -Name '' -Force -TurnOff; Remove-VM -Name '' -Force; Remove-Item 'C:\\ProgramData\\Microsoft\\Windows\\Virtual Hard Disks\\.vhdx' -Force\""

Or use scripts/destroy-vm.ps1:

scp scripts/destroy-vm.ps1 hyperv-host:C:/Users/youruser/Downloads/
ssh hyperv-host "powershell -ExecutionPolicy Bypass -File C:\\Users\\youruser\\Downloads\\destroy-vm.ps1 -VMName "

Critical Gotchas

See references/gotchas.md for full details. Top blockers:

  1. Sparse VHDX: fsutil sparse setflag 0 BEFORE Resize-VHD or error 0xC03A001A
  2. Network config: Must include match: driver: hv_netvsc or VM gets no IP
  3. Permissions: icacls /grant "NT VIRTUAL MACHINE\Virtual Machines:(F)" or Start-VM fails
  4. Secure Boot Off: Ubuntu cloud images aren't signed for Hyper-V
  5. Cloud-init runs once: No redo. Delete VM + VHDX and start over
  6. Don't batch PowerShell: Run Hyper-V commands one at a time
  7. All commands need elevated PowerShell
  8. Docker Compose v2: Install via curl in runcmd, NOT apt
  9. IP discovery: Use ARP scan, not Get-VMNetworkAdapter (needs linux-tools-virtual)

相关技能

以 AI 机器人身份加入视频会议,提供语音、虚拟形象与屏幕共享四种模式。

作者 johnpatternai21 次安装8 星标

docx

官方

借助 docx npm 包、直接 XML 编辑与 pandoc,完成 Word .docx 与 .dotx 文件的创建、读取与修改。

作者 Anthropic177.5k 星标

为 ChatGPT Apps SDK 生成基于最新官方文档的 MCP 服务端与小组件脚手架

作者 OpenAI27.5k 星标

获得一套为项目定制的设计系统规则文件,让 AI 编码代理在实现 Figma 设计时自动遵循你的项目约定。

作者 OpenAI27.5k 星标

speech

官方

通过 OpenAI Audio API 将文本转为语音,支持批量生成与内置音色预设。

作者 OpenAI27.5k 星标

solomonneas 的更多技能

浏览全部技能

Essential penetration testing command reference. Quick lookup for nmap, Metasploit, hydra, john, nikto, gobuster, and other offensive security tools. Covers...

作者 Solomon Neas65 次安装1 星标

Memory forensics with Volatility and related tools. Acquire RAM dumps, extract processes and DLLs, investigate rootkits and fileless malware, recover credent...

作者 solomonneas30 次安装1 星标

This skill should be used when the user asks to "run pentest commands", "scan with nmap", "use metasploit exploits", "crack passwords with hydra or john", "s...

作者 solomonneas36 次安装

Expert malware analysis for defensive security research. Static and dynamic analysis, sandbox triage, IOC extraction, unpacking, and malware family identific...

作者 solomonneas31 次安装

Knowledge card memory system with semantic search. Agents wake up fresh each session but remember everything through atomic ~350-token cards with YAML frontm...

作者 solomonneas28 次安装

Network traffic analysis with Wireshark and tshark. Capture packets, write display and BPF filters, follow TCP/UDP/TLS streams, detect C2 beacons, troublesho...

作者 solomonneas27 次安装