用 hdiutil 创建加密磁盘映像
在终端中直接生成 AES-256 加密的 .dmg 加密容器,无需打开磁盘工具。
运行 `hdiutil create -size 500m -fs APFS -encryption AES-256 -stdinpass ~/SecureVault.dmg`,按提示输入密码。
01命令
命令
$ hdiutil create -size 500m -fs APFS -encryption AES-256 -stdinpass ~/SecureVault.dmg02作用说明
hdiutil 是磁盘工具背后的命令行引擎,可以脚本化整个加密保险箱流程:-stdinpass 从标准输入读取密码,避免密码出现在 shell 历史或进程列表里。生成的 .dmg 双击时必须输入密码才能挂载。创建时可用 -srcfolder 直接放入内容,之后还能用 `hdiutil resize` 扩容。
03风险
04撤销
撤销
$ hdiutil detach /Volumes/SecureVault && rm ~/SecureVault.dmg05来源
- macOS hdiutil — create, attach and detach disk images依据: Documents hdiutil create with -encryption AES-256, -stdinpass, -size and filesystem options.
最后验证: 2026-09-17 · 分类: 系统与设置