虚拟机安装苹果实践,在Windows10系统,安装Virtual Box7.1.6,安装虚拟苹果Monterey版本Monterey (macOS 12) 。碰到的主要问题是安装光盘不像Windows那么容易拿到,而且根据网上很多文章制作的光盘,在viritualBox里都无法引导启动,最后只有一个big sur版本的iso可以启动,见后面调试部分。
下载安装软件
经过多次尝试,只有这个链接里面拿到的Mac OS 盘是可以在virtualBox里引导启动的。
这篇文档里有个big sur版本mac的下载地址:VirtualBox 7.0 安装 macOS big sur + Windows 11系统-零度博客
以下制作的iso光盘都无法在VirtualBox里引导启动,留档。
尝试下载10.12版本(无法启动)
先下载一个较老的版本10.12,下载页面:如何下载和安装 macOS - 官方 Apple 支持 (中国)
具体下载链接:http://updates-http.cdn-apple.com/2019/cert/061-39476-20191023-48f365f4-0015-4c41-9f44-39d3d2aca067/InstallOS.dmg
转换格式,到华军软件园下载转换软件:dmg转iso(dmg2img)下载2025最新pc版_dmg转iso(dmg2img)电脑版官方免费下载_华军软件园
使用命令dmg2img.exe InstallOS.dmg InstallOS.iso 转换:
e:\360Downloads>e:\tools\dmg2img\dmg2img.exe InstallOS.dmg InstallOS.isodmg2img v1.6.2 is derived from dmg2iso by vu1tur (to@vu1tur.eu.org)InstallOS.dmg --> InstallOS.isoreading property list, 306327 bytes from address 5007575287 ...decompressing:
opening partition 0 ... 100.00% ok
opening partition 1 ... 100.00% ok
opening partition 2 ... 100.00% ok
opening partition 3 ... 100.00% ok
opening partition 4 ... 100.00% ok
opening partition 5 ... 100.00% ok
opening partition 6 ... 100.00% ok
opening partition 7 ... 100.00% ok
opening partition 8 ... 100.00% okArchive successfully decompressed as InstallOS.iso
经测试,这样转换的iso文件不行。
下载Big Sur和Monterey并转换dmg到iso文件(无法启动)
如何在Windows 10的VirtualBox中安装macOS High Sierra:如何在Windows 10的VirtualBox中安装macOS High Sierra-腾讯云开发者社区-腾讯云
查看下载的安装文件,在/Applications
Install macOS Big Sur.app
Install macOS Monterey.app
具体来说,Monterry的盘在这里:/Applications/Install macOS Monterey.app/Contents/SharedSupport
ls -l
total 24235624
-rw-r--r-- 1 root wheel 12408638012 2 27 20:19 SharedSupport.dmg
创建空白磁盘
hdiutil create -o /tmp/HighSierra.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil create -o /tmp/Monterey.cdr -size 12412m -layout SPUD -fs HFS+J
挂载空白磁盘
hdiutil attach /tmp/Monterey.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
挂载成功
hdiutil attach /tmp/Monterey.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
/dev/disk3 Apple_partition_scheme
/dev/disk3s1 Apple_partition_map
/dev/disk3s2 Apple_HFS /Volumes/install_build
从安装程序中还原安装镜像到挂载的空白磁盘
asr restore --source "/Applications/Install macOS Monterey.app/Contents/SharedSupport/SharedSupport.dmg" --target /Volumes/Install_build --noprompt --noverify -erase
注意,原文档里参数只有一个“-”,会报错,要修改成两个"--"
输出信息说:
Restored target device is /dev/disk3s2.
也就是/dev/disk3s2 这个盘,挂载点为/Volumes/install_build ,已经做成MacOS启动盘了
因为前面知道创建的空白磁盘是/dev/disk3,所以直接卸载它就行了。可以到“访达”里用鼠标点击卸载,也可以用命令
hdiutil detach /dev/disk3
将dmg变成iso
hdiutil convert /tmp/Monterey.cdr.dmg -format UDTO -o /tmp/Monterey.iso
完成:created: /tmp/Monterey.iso.cdr
但是用这个文件在virtualbox里还是无法启动。
尝试学习用hdiutil转换dmg到iso(无法启动)
hdiutil makehybrid -iso -o Monterey.iso /tmp/Monterey.cdr.dmg
执行这些命令:
首先,运行以下命令以创建空白磁盘映像:
hdiutil create -o /tmp/HighSierra.cdr -size 7316m -layout SPUD -fs HFS+J
接下来,挂载空白镜像:
hdiutil attach /tmp/HighSierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
现在,您将从安装程序中还原BaseSystem.dmg到新安装的映像:
asr restore -source /Applications/Install/macOS/High/Sierra.app/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/Install_build -noprompt -noverify -erase
请注意,执行完此操作后,目标挂载点的名称已更改为“ OS X Base System / System”。你几乎已经完成!卸载图像:
hdiutil detach /Volumes/OS/X/Base/System
最后,将您创建的映像转换为ISO文件:
hdiutil convert /tmp/HighSierra.cdr.dmg -format UDTO -o /tmp/HighSierra.iso
将ISO移至桌面:
mv /tmp/HighSierra.iso.cdr ~/Desktop/HighSierra.iso
您已经拥有可引导的High Sierra ISO文件!
此方法未测试成功。
创建virtualbox mac虚拟机
知乎一篇文章讲到这样:
VBoxManage.exe modifyvm MacOS --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbffVBoxManage setextradata MacOS "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"VBoxManage setextradata MacOS "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"VBoxManage setextradata MacOS "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"VBoxManage setextradata MacOS "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"VBoxManage setextradata MacOS "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1# 修改屏幕分辨率为 1440 * 900
VBoxManage setextradata MacOS VBoxInternal2/EfiGopMode 4# VirtualBox5.2版本修改分辨率命令
VBoxManage setextradata MacOS VBoxInternal2/EfiGraphicsResolution 1440x900
其实应该不用吧,现在直接有macos的虚拟机选项了。
苹果版本号对应表:
-
Sonoma (macOS 14)
- 发布年份:2023
- 主要特性:增强的桌面小部件、改进的游戏体验、Safari 的新功能等。
-
Ventura (macOS 13)
- 发布年份:2022
- 主要特性:引入了 Stage Manager、改进的邮件和信息应用、增强的隐私保护等。
-
Monterey (macOS 12)
- 发布年份:2021
- 主要特性:引入了 Focus 模式、快捷指令、Universal Control 等。
-
Big Sur (macOS 11)
- 发布年份:2020
- 主要特性:全新的用户界面设计、控制中心、改进的 Safari 浏览器等。
-
Catalina (macOS 10.15)
- 发布年份:2019
- 主要特性:引入了 Sidecar、屏幕时间、完全移除 iTunes 等。
-
Mojave (macOS 10.14)
- 发布年份:2018
- 主要特性:引入了黑暗模式、桌面堆栈、改进的屏幕截图工具等。
-
High Sierra (macOS 10.13)
- 发布年份:2017
- 主要特性:引入了 APFS 文件系统、改进的照片应用、Metal 2 图形技术等。
-
Sierra (macOS 10.12)
- 发布年份:2016
- 主要特性:引入了 Siri、优化的文件管理、Apple Pay 支持等。
-
El Capitan (macOS 10.11)
- 发布年份:2015
- 主要特性:改进的窗口管理、Split View、增强的 Spotlight 搜索等。
-
Yosemite (macOS 10.10)
- 发布年份:2014
- 主要特性:全新的用户界面设计、Handoff 功能、改进的通知中心等。
其它学习
下载mac软件
参考:Making the installer in macOS | OpenCore Install Guide
Using App Store
From a macOS machine that meets the requirements of the OS version you want to install, go directly to the App Store and download the desired OS release and continue to Setting up the installer.
#
Command Line Software Update Utility
Open a terminal window then copy and paste the below command:
sh
softwareupdate --list-full-installers; echo; echo "Please enter version number you wish to download:"; read REPLY; [ -n "$REPLY" ] && softwareupdate --fetch-full-installer --full-installer-version "$REPLY"

This gives you a list of available releases you can choose from. Once downloaded it will be saved in your Applications folder. You can continue to Setting up the installer.
#
Munki's InstallInstallMacOS utility
Note for users running macOS Monterey 12.3 or above
In order to run it, just copy and paste the below command in a terminal window:
sh
mkdir -p ~/macOS-installer && cd ~/macOS-installer && curl https://raw.githubusercontent.com/munki/macadmin-scripts/main/installinstallmacos.py > installinstallmacos.py && sudo
python installinstallmacos.py

As you can see, we get a nice list of macOS installers. If you need a particular versions of macOS, you can select it by typing the number next to it. For this example we'll choose 10:

This is going to take a while as we're downloading the entire 8GB+ macOS installer, so it's highly recommended to read the rest of the guide while you wait.
Once finished, you'll find in your ~/macOS-Installer/ folder a DMG containing the macOS Installer, called Install_macOS_11.1-20C69.dmg for example. Mount it and you'll find the installer application.
• Note: We recommend to move the Install macOS.app into the /Applications folder, as we'll be executing commands from there.
• Note 2: Running Cmd+Shift+G in Finder will allow you to easily jump to ~/macOS-installer


From here, jump to Setting up the installer to finish your work. If you want to check the integrity of your download, you can check this repository of checks
softwareupdate --list-full-installers; echo; echo "Please enter version number you wish to download:"; read REPLY; [ -n "$REPLY" ] && softwareupdate --fetch-full-installer --full-installer-version "$REPLY"
参考如何在windows下安装mac虚拟机安装 | PingCode智库
使用VirtualBox安装macOS
1、安装Oracle VM VirtualBox
下载并安装VirtualBox。完成后,安装VirtualBox扩展包以获得更好的性能和更多的功能。
2、创建新的虚拟机
打开VirtualBox,点击“新建”。
- 输入虚拟机名称,类型选择“Mac OS X”,版本选择对应的macOS版本,点击“下一步”。
- 分配内存大小,建议至少分配8GB,点击“下一步”。
- 创建虚拟硬盘,选择“VDI(VirtualBox磁盘映像)”,点击“下一步”。
- 硬盘类型选择“动态分配”,点击“下一步”。
- 指定虚拟硬盘文件的位置和大小,点击“创建”。
3、加载macOS镜像文件
- 右键点击创建好的虚拟机,选择“设置”。
- 在“系统”选项中,确保启用“EFI(特殊操作系统的唯一固件接口)”。
- 在“存储”选项中,选择“空”,然后点击光盘图标,选择“选择虚拟光盘文件”,选择macOS镜像文件。
4、运行命令行配置(这个非必须)
关闭VirtualBox,打开命令提示符(以管理员身份运行),运行以下命令来配置虚拟机:
cd "C:Program FilesOracleVirtualBox"
VBoxManage modifyvm "你的虚拟机名称" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "你的虚拟机名称" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "你的虚拟机名称" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "你的虚拟机名称" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "你的虚拟机名称" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "你的虚拟机名称" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
5、启动虚拟机并安装macOS
- 打开VirtualBox,启动虚拟机。
- 虚拟机会启动macOS安装程序,按照提示进行安装。
实践下来,启动非常慢,大约要20-30分钟才能进入mac安装界面
调试
启动后无法从光盘启动。
解决中。经过多次尝试,只有这个链接里面拿到的Mac OS 盘是可以在virtualBox里引导启动的。
这篇文档里有个big sur版本mac的下载地址:VirtualBox 7.0 安装 macOS big sur + Windows 11系统-零度博客
这个盘是可以启动的
启动后报错:
Failed to query SMC value from the host (VERR_INVALID_HANDLE).
返回 代码: | E_FAIL (0x80004005) |
组件: | ConsoleWrap |
界面: | IConsole {6ac83d89-6ee7-4e33-8ae6-b257b2e81be8} |
尝试禁用禁用SMC查询
VBoxManage.exe setextradata "MacOS" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 0
确实管用,又重复原来无法从光盘启动的问题了。光盘启动问题解决见上面。