系统环境:Ubuntu 16.04
1.先安装好KVM 不属于本教程内容2.使用 https://github.com/kholia/OSX-KVM 方案
3.创建磁盘空间
- qemu-img create -f qcow2 /kvm/mac/mac1012.img 200G
复制代码
4.kvm安装MAC配置文件- <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>
- <uuid>c757b31e-115f-4d1a-b574-0ae7b3cc8a58</uuid>
- <os>
- <type arch='x86_64' machine='pc-q35-2.4'>hvm</type>
- <kernel>/Install_macOS_Sierra_OS_X_10.12/enoch_rev2839_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='/kvm/mac/mac1012.img'/>
- <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'/>
- <mac address='52:54:00:3d:f8:25'/>
- <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='5996' 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=/Install_macOS_Sierra_OS_X_10.12/Install_macOS_Sierra_(OS_X_10.12).iso'/>
- </qemu:commandline>
- </domain>
复制代码
保存为 macOS-libvirt.xml终端运行:
- virsh define /KVM/macOS-libvirt.xml
复制代码
5.终端运行:- echo 1 > /sys/module/kvm/parameters/ignore_msrs
复制代码
开机执行
- vim /etc/rc.local
- echo 1 > /sys/module/kvm/parameters/ignore_msrs
复制代码
6.安装selinux 并设置重启
- sudo apt-get install selinux
- #设置selinux=permissive
- reboot
复制代码 7.kvm控制台启动OSX-KVM选磁盘工具
格式磁盘
退出磁盘工具,打开终端
执行:- cp -av /Extra /Volumes/KVMDisk
复制代码 9.退出终端,按提示安装mac
10.关闭mac
11.使用配置文件创建mac虚拟机
- <domain type='kvm' xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">
- <name>sierra</name>
- <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>/Install_macOS_Sierra_OS_X_10.12/enoch_rev2839_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/kvm-spice</emulator>
- <disk type='file' device='disk'>
- <driver name='qemu' type='qcow2'/>
- <source file='/kvm/mac/mac1012.img'/>
- <target dev='sda' bus='sata'/>
- <boot order='1'/>
- <address type='drive' controller='0' bus='0' target='0' unit='0'/>
- </disk>
- <interface type='bridge'>
- <source bridge='br0'/>
- <model type='e1000-82545em'/>
- <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
- </interface>
- <input type='mouse' bus='usb'/>
- <input type='keyboard' bus='usb'/>
- <graphics type='vnc' port='5996' 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='0x02' 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:commandline>
- </domain>
复制代码 保存为sierra.xml
7.执行:- virsh define /KVM/sierra.xml
复制代码
8.运行虚拟机,就可以快乐的玩MAC咯~(vnc后可以远程协助哦)
9.设置服务器开机自动启动虚拟机
|