QEMU虚拟化安装MacOS系统


需要的文件:

  1. 已转换过格式的 BaseSystem.img
  2. ESP.qcow2
  3. qemu-system-x86_64 >= 4.2.0
  4. UEFI 固件文件 OVMF_CODE.fd 和 OVMF_VARS-1024×768.fd

创建系统硬盘:

qemu-img create -f qcow2 system.qcow2 128G

创建虚拟机安装 MacOS 系统

qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-machine q35,accel=kvm \
-smp 2 \
-cpu Penryn,vendor=GenuineIntel,kvm=on,+sse3,+sse4.2,+aes,+xsave,+avx,+xsaveopt,+xsavec,+xgetbv1,+avx2,+bmi2,+smep,+bmi1,+fma,+movbe,+invtsc \
-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
-smbios type=2 \
-drive if=pflash,format=raw,readonly,file=OVMF_CODE.fd \
-drive if=pflash,format=raw,file=OVMF_VARS-1024x768.fd \
-vga virtio \
-usb -device usb-kbd -device usb-tablet \
-netdev user,id=net0 \
-device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:0e:0d:25 \
-device ich9-ahci,id=sata \
-drive id=ESP,if=none,format=qcow2,file=ESP.qcow2 \
-device ide-hd,bus=sata.2,drive=ESP \
-drive id=InstallMedia,format=raw,if=none,file=BaseSystem.img \
-device ide-hd,bus=sata.3,drive=InstallMedia \
-drive id=SystemDisk,if=none,file=system.qcow2 \
-device ide-hd,bus=sata.4,drive=SystemDisk \
-vnc 0.0.0.0:0,to=99,id=default

qemu命令转换为 xml 文件

virsh domxml-from-native qemu-argv macos.args