hdiutil is deprecated in macOS 27 Golden Gate
hdiutil is deprecated in macOS 27 Golden Gate
hdiutil 在 macOS 27 Golden Gate 中被弃用
hdiutil is deprecated in macOS 27 Golden Gate August 14 2026 The macOS command-line tool hdiutil is used to manipulate disk images. From the WHAT’S NEW section of man hdiutil on the latest macOS 27 Golden Gate beta: In macOS 27.0, hdiutil is deprecated. Use diskutil image instead for all disk image operations. diskutil image provides subcommands for attach, create, resize, info, and chpass. ASIF (Apple Sparse Image Format) images are only supported by diskutil image and are not supported by hdiutil.
hdiutil 在 macOS 27 Golden Gate(2026 年 8 月 14 日)中被弃用。macOS 命令行工具 hdiutil 用于操作磁盘映像。根据最新 macOS 27 Golden Gate 测试版中 man hdiutil 的“新增功能”(WHAT’S NEW)部分显示:在 macOS 27.0 中,hdiutil 已被弃用。所有磁盘映像操作请改用 diskutil image。diskutil image 提供了用于挂载(attach)、创建(create)、调整大小(resize)、查看信息(info)和修改密码(chpass)的子命令。ASIF(Apple Sparse Image Format)映像仅由 diskutil image 支持,hdiutil 不再支持。
There’s also a DEPRECATION NOTICE at the top of the man page that lists the diskutil replacements for hdiutil subcommands. The majority of options from hdiutil appear to be preserved in diskutil, though under different names. However, some hdiutil options are missing, for example -puppetstrings: provide progress output that is easy for another program to parse. PERCENTAGE outputs can include the value -1 which means hdiutil is performing an operation that will take an indeterminate amount of time to complete. Any program trying to interpret hdiutil’s progress should use -puppetstrings.
手册页顶部还有一个“弃用通知”(DEPRECATION NOTICE),列出了 hdiutil 子命令对应的 diskutil 替代方案。hdiutil 的大部分选项似乎都保留在 diskutil 中,尽管名称有所不同。然而,一些 hdiutil 选项缺失了,例如 -puppetstrings:该选项提供易于其他程序解析的进度输出。百分比输出可能包含值 -1,这意味着 hdiutil 正在执行一项需要不确定时间才能完成的操作。任何试图解析 hdiutil 进度的程序都应该使用 -puppetstrings。
Also missing are some options specific to hdiutil create -srcfolder: -[no]crossdev -[no]scrub -[no]anyowners -skipunreadable -[no]atomic -copyuid
此外,一些特定于 hdiutil create -srcfolder 的选项也缺失了,包括:-[no]crossdev、-[no]scrub、-[no]anyowners、-skipunreadable、-[no]atomic 和 -copyuid。
I attempted to compare hdiutil and diskutil on Golden Gate by performing a backup of the user home folder, something I do daily on my MacBook Pro with macOS Sequoia. First: time hdiutil create -encryption -format UDZO -noatomic -noscrub -srcfolder /Users/stupiduser -stdinpass -verbose /Users/Shared/hdiutil.dmg This took around 110 to 115 seconds on average. It’s crucial to note that hdiutil triggers an authentication prompt, because one of the files is, annoyingly, owned by the root user.
我尝试在 Golden Gate 上通过备份用户主文件夹来对比 hdiutil 和 diskutil,这正是我在运行 macOS Sequoia 的 MacBook Pro 上每天都会做的事情。首先:执行 time hdiutil create -encryption -format UDZO -noatomic -noscrub -srcfolder /Users/stupiduser -stdinpass -verbose /Users/Shared/hdiutil.dmg。平均耗时约 110 到 115 秒。值得注意的是,hdiutil 会触发身份验证提示,因为其中一个文件令人烦恼地归 root 用户所有。
From the Terminal output: copy-helper[2598:97396] uid 501 does not have ownership of /Users/stupiduser/Library/Group Containers/group.com.apple.secure-control-center-preferences/Library/Preferences/group.com.apple.secure-control-center-preferences.av.plist - setting needAuth to YES Scanning… Error 80 (Authentication error). /Users/stupiduser/Library/Group Containers/group.com.apple.secure-control-center-preferences/Library/Preferences/group.com.apple.secure-control-center-preferences.av.plist: Authentication error The disk image creation continues and finishes successfully after authenticating with admin credentials.
终端输出显示:copy-helper[2598:97396] uid 501 does not have ownership of ... - setting needAuth to YES。扫描中……错误 80(身份验证错误)。在输入管理员凭据进行身份验证后,磁盘映像创建过程继续并成功完成。
Now the new method: time diskutil image —stdinpassphrase —verbose create —encrypt from —format UDZO /Users/stupiduser /Users/Shared/diskutil.dmg This simply fails and, despite the verbose option, doesn’t tell you why. [100% completed] Error: Failed to create disk image: The operation couldn’t be completed. Operation not permitted
现在尝试新方法:time diskutil image --stdinpassphrase --verbose create --encrypt from --format UDZO /Users/stupiduser /Users/Shared/diskutil.dmg。结果直接失败,尽管使用了 verbose 选项,但并没有说明原因。[100% 完成] 错误:无法创建磁盘映像:操作无法完成。操作不允许。
Luckily, I guessed the reason, the root-owned file. Unlike hdiutil, diskutil does not trigger an authentication prompt. Thus, I had to delete the root-owned file to get diskutil to work. [100% completed] /Users/Shared/diskutil.dmg created Again, not particularly verbose. However, the progress percentage does update in place during the disk image creation, so there is some kind of substitute for the hdiutil -puppetstrings option.
幸运的是,我猜到了原因,就是那个归 root 用户所有的文件。与 hdiutil 不同,diskutil 不会触发身份验证提示。因此,我必须删除该文件才能让 diskutil 正常工作。[100% 完成] /Users/Shared/diskutil.dmg 已创建。同样,输出信息并不特别详细。不过,进度百分比在创建过程中会原地更新,因此这算是对 hdiutil -puppetstrings 选项的一种替代。
The good news is that diskutil was significantly faster, taking around 40 to 45 seconds on average to finish, more than a minute faster than hdiutil. Also, the resulting dmg file from diskutil was smaller, 2.8 GB, as opposed to 2.89 GB from hdiutil. I mounted the two disk images and used the FileMerge app (embedded inside the Xcode app) to compare them. Aside from a few files that were naturally modified in the few minutes between the two command-line invocations, the main difference was that the hdiutil disk image included the ~/.Trash/ folder, while the diskutil disk image did not.
好消息是 diskutil 的速度明显更快,平均耗时约 40 到 45 秒,比 hdiutil 快了一分多钟。此外,diskutil 生成的 dmg 文件更小(2.8 GB),而 hdiutil 生成的文件为 2.89 GB。我挂载了这两个磁盘映像,并使用 FileMerge 应用(内置于 Xcode 中)进行了对比。除了两次命令行调用之间几分钟内自然修改的少数文件外,主要区别在于 hdiutil 的磁盘映像包含了 ~/.Trash/ 文件夹,而 diskutil 的磁盘映像则没有。
In other words, diskutil behaved as if the -scrub option of hdiutil were enabled. -[no]scrub do [not] skip temporary files when imaging a volume. Scrubbing is the default when the source is the root of a mounted volume. Scrubbed items include trashes, temporary directories, swap files, etc. So it appears that diskutil in Golden Gate needs some work: Improve verbose logging, Handle file permission problems, Add the -[no]scrub option.
换句话说,diskutil 的表现就像启用了 hdiutil 的 -scrub 选项一样。-[no]scrub 表示在对卷进行映像时是否跳过临时文件。当源是挂载卷的根目录时,默认会进行清理(Scrubbing)。清理的项目包括废纸篓、临时目录、交换文件等。因此,Golden Gate 中的 diskutil 似乎还需要改进:改善详细日志记录、处理文件权限问题、添加 -[no]scrub 选项。
To conclude, I don’t understand why hdiutil needs to be deprecated when the same functionality will live on in diskutil. For some reason, Apple seems intent on breaking longtime workflows and scripts. Many years ago I actually worked on an app, Knox, that calls hdiutil directly. If hdiutil were removed from macOS, that would completely break such an app.
总而言之,我不明白既然 diskutil 保留了相同的功能,为什么还要弃用 hdiutil。出于某种原因,苹果似乎执意要破坏长期存在的工作流程和脚本。多年前,我曾开发过一款名为 Knox 的应用,它直接调用了 hdiutil。如果 hdiutil 从 macOS 中移除,这类应用将彻底瘫痪。
By the way, both hdiutil and diskutil on Golden Gate still suffer from the bug I blogged about last year, Inaccessible .bnnsir files on macOS Sequoia. A couple days ago I got a ridiculous update to the bug report I filed with Apple, “hdiutil create copy error with Siri CoreSpeech .bnnsir files” (FB17162985). Despite giving Apple 100% reliable steps to reproduce, they asked me if the issue still occurred in the latest beta, and if it does, then I should submit an iOS sysdiagnose. Yes, Apple requested an iOS sysdiagnose for a macOS bug. And needless to say, the latest Golden Gate beta did not magically fix the bug.
顺便提一下,Golden Gate 上的 hdiutil 和 diskutil 仍然存在我去年博客中提到的 Bug:macOS Sequoia 上无法访问的 .bnnsir 文件。几天前,我收到了一份关于我向苹果提交的 Bug 报告(FB17162985,“hdiutil 创建时出现 Siri CoreSpeech .bnnsir 文件复制错误”)的荒谬更新。尽管我提供了 100% 可复现的步骤,他们还是问我这个问题在最新测试版中是否仍然存在,如果存在,我应该提交一份 iOS 系统诊断(sysdiagnose)。没错,苹果竟然要求为 macOS 的 Bug 提交 iOS 系统诊断。不用说,最新的 Golden Gate 测试版并没有奇迹般地修复这个 Bug。