一、在macOS系统中生成ISO文件:
1、在App Store中搜索、下载macOS Sierra系统。
1
|
App Store --> macos --> macOS Sierra --> DOWNLOAD |
2、通过github下载OSX-KVM文件:
1
|
sh-3.2 # git clone https://github.com/kholia/OSX-KVM.git |
3、进入OSX-KVM目录,将下载的系统文件生成ISO文件(Install_macOS_10.12.6_Sierra.iso):
1
|
sh-3.2 # ./create_install_iso.sh |
二、在KVM机器中配置、创建虚拟机:
OS:Ubuntu 16.04.3
KVM:QEMU 2.5
1、安装QEMU及虚拟机管理工具:
1
|
root@rock-desktop:/ # apt-get install qemu uml-utilities virt-manager |
2、下载OSX-KVM配置文件:
1
|
root@rock-desktop:/ # git clone https://github.com/kholia/OSX-KVM.git |
3、创建虚拟硬盘文件:
1
|
root@rock-desktop:/ # qemu-img create -f qcow2 /usr/local/src/vm/mac_hdd.qcow2 40G |
4、修改虚拟机配置文件:
1
|
root@rock-desktop:/ # vim /usr/local/src/OSX-KVM/macOS-libvirt.xml |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<domain type = 'kvm' xmlns:qemu= 'http://libvirt.org/schemas/domain/qemu/1.0' > <name>OSX_KVM< /name > <title>OSX-KVM< /title > <description> # echo 1 > /sys/module/kvm/parameters/ignore_msrs</description> <memory unit= 'KiB' >4194304< /memory > <currentMemory unit= 'KiB' >4194304< /currentMemory > <vcpu placement= 'static' >2< /vcpu > <os> < type arch= 'x86_64' machine= 'pc-q35-2.4' >hvm< /type > <kernel> /usr/local/src/OSX-KVM/enoch_rev2889_boot < /kernel > < /os > <features> <acpi/> <kvm> <hidden state= 'on' /> < /kvm > < /features > <cpu mode= 'custom' match= 'exact' > <model fallback= 'allow' >Penryn< /model > < /cpu > <devices> <emulator> /usr/bin/qemu-system-x86_64 < /emulator > <disk type = 'file' device= 'disk' > <driver name= 'qemu' type = 'qcow2' /> < source file = '/usr/local/src/vm/mac_hdd.qcow2' /> <target dev= 'sda' bus= 'sata' /> <boot order= '1' /> <address type = 'drive' controller= '0' bus= '0' target= '0' unit= '0' /> < /disk > <interface type = 'network' > < source network= 'default' /> <model type = 'e1000-82545em' /> <address type = 'pci' domain= '0x0000' bus= '0x02' slot= '0x02' function = '0x0' /> < /interface > <input type = 'mouse' bus= 'usb' /> <input type = 'keyboard' bus= 'usb' /> <graphics type = 'vnc' port= '5900' autoport= 'no' listen= '127.0.0.1' keymap= 'en-us' > <listen type = 'address' address= '127.0.0.1' /> < /graphics > <video> <model type = 'vmvga' vram= '16384' heads= '1' /> <address type = 'pci' domain= '0x0000' bus= '0x00' slot= '0x01' function = '0x0' /> < /video > <memballoon model= 'none' /> < /devices > <qemu:commandline> <qemu:arg value= '-device' /> <qemu:arg value= 'isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc' /> <qemu:arg value= '-smbios' /> <qemu:arg value= 'type=2' /> <qemu:arg value= '-k' /> <qemu:arg value= 'en-us' /> <qemu:arg value= '-cpu' /> <qemu:arg value= 'Penryn,vendor=GenuineIntel' /> <qemu:arg value= '-device' /> <qemu:arg value= 'ide-drive,bus=ide.1,drive=MacDVD' /> <qemu:arg value= '-drive' /> <qemu:arg value= 'id=MacDVD,if=none,snapshot=on,file=/usr/local/src/iso/Install_macOS_Sierra_OS_X_10.12.iso' /> < /qemu :commandline> < /domain > |
5、创建虚拟机:
1
|
root@rock-desktop:/ # virsh define /usr/local/src/OSX-KVM/macOS-libvirt.xml |
注:安装镜像ISO文件用原版的会有引导的问题,要找修改过Kernel的。