Esxi之kvm安装黑苹果
环境
•debian server(无桌面)•kvm虚拟机
安装
安装黑苹果
•安装依赖
sudo apt-get install qemu-system qemu-utils python3 python3-pip
•下载git仓库macOS-Simple-KVM
git clone https://github.com/foxlet/macOS-Simple-KVM.git
•初始化镜像和初始化kvm硬盘(建议至少120G以上)
cd macOS-Simple-KVM#可能会失败,重复到成功./jumpstart.shqemu-img create -f qcow2 MyDisk.qcow2 120G
•启动黑苹果
HEADLESS=1 MEM=8G CPUS=4 SYSTEM_DISK=MyDisk.qcow2 ./headless.sh
•使用VNC软件连接debian服务器•安装黑苹果
先初始化硬盘,后安装镜像,初始化安装可能会失败,重复到可以为止
桥接网络
•安装依赖
apt install bridge-utilsapt install uml-utilitiesapt install net-tools
•编辑启动脚本macos.sh
#启动桥接网卡,ens192为物理网卡,请自行修改brctl addbr br0ip addr flush dev ens192brctl addif br0 ens192tunctl -t tap0 -u rootbrctl addif br0 tap0ifconfig ens192 upifconfig tap0 upifconfig br0 up#dhclient -v br0ifconfig br0 192.168.3.28 netmask 255.255.255.0route add default gw 192.168.3.1#启动黑苹果cd /root/macOS-Simple-KVMsh startmacos.sh
•复制headless.sh文件为startmacos.sh,并修改相关参数,以下为个人修改参考
#!/bin/bashOSK="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"VMDIR=$PWDOVMF=$VMDIR/firmwareqemu-system-x86_64 \-enable-kvm \-m 12G \-machine q35,accel=kvm \-smp 4,cores=4 \-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="$OSK" \-smbios type=2 \-drive if=pflash,format=raw,readonly,file="$OVMF/OVMF_CODE.fd" \-drive if=pflash,format=raw,file="$OVMF/OVMF_VARS-1024x768.fd" \-vga qxl \-usb -device usb-kbd -device usb-tablet \-netdev tap,id=net0,ifname=tap0,script=no,downscript=no \-device vmxnet3,netdev=net0,id=net0,mac=52:54:00:0e:0d:20 \-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=MyDisk.qcow2 \-device ide-hd,bus=sata.4,drive=SystemDisk \-nographic -vnc :0 -k en-us
开机启动
•创建服务,创建文件/lib/systemd/system/macos.service
[Unit]Description=macos[Service]Type=simpleExecStart=/usr/bin/sh /root/macos.shUser=root[Install]WantedBy=multi-user.target
•开机启动
systemctl enable macos
参考文献
•macOS-Simple-KVM[1]•qemu-networking[2]
引用链接
[1] macOS-Simple-KVM: https://github.com/foxlet/macOS-Simple-KVM[2] qemu-networking: https://gist.github.com/extremecoders-re/e8fd8a67a515fee0c873dcafc81d811c
