Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Resize disk image with hdiutil in sandbox environment

I am using macOS virtualization farmework and able to create nad and run VMS. I need to resize the disk images using hdiutil in app sandbox environment. Is that possible? i tried disabling sandbox and it worked ok. But with sandbox i get the error message device is not configured. If this cant be done in sandbox what could be the alternative way to to achive this in sandboxed app.

thanks

Answered by DTS Engineer in 835620022
Yes it works.

Well, that’s cool.

Unfortunately it puts the kibosh on all the workaround ideas I’d been thinking of. It might’ve been feasible for you to manually resize less complex disk images, but doing that for a .dmg containing a bootable macOS is not feasible. You really need hdiutil for this.

I’m gonna recommend that you file a couple of bugs here:

  • A bug report asking that hdiutil support this use case. Resizing a macOS boot image from a Mac App Store hypervisor app is a reasonable thing to do, and it’s annoying that it’s being blocked by the sandbox.

  • A separate enhancement request for an API to manipulate disk images programatically. Relying on hdiutil for these sorts of tasks has always been annoying, and it’s gonna get increasingly problematic as we get further down the virtualisation path.

Please post your bug numbers, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I don’t think you’ll be able to make this work, at least not directly. The hdiutil tool is primarily focused on accomplishing user-level tasks from within Terminal. It was never really intended to be used from within App Sandbox, even though in this case, at least conceptually, it’s just modifying a file.

However, there may be other options, depending on your specific situation.

Is your app sandboxed because you plan to ship in the Mac App Store? Or just because it’s the right thing to do?

How does this disk image fit into your virtualisation product? Specifically, what overall format is it? And what file system do you have on it? And how are you attaching it to your VM? And is your VM focused on macOS? Or Linux? Or both?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is your app sandboxed because you plan to ship in the Mac App Store? Or just because it’s the right thing to do?

I have the only option to distibute it to appstore because i cant manage the payment details outside of the appstore because it is very small business.

How does this disk image fit into your virtualisation product? Specifically, what overall format is it? And what file system do you have on it? And how are you attaching it to your VM? And is your VM focused on macOS? Or Linux? Or both?

The disk image format is img i attach it as a virtio blcok device as metnioned. i just followed this article Creating mac os virtual machine for creating and attaching to the virtual machine.

The vm is focused on both linux and macOS. the files system in mac os apfs and in linux it is ext4.

What are the other options i have got.

By the way this is the app VirtualProg i have got in the appstore.

Resizing the hard disk image within the app will add value to the product. that is i am here.

thanks

i just followed this article [Running macOS in a virtual machine on Apple silicon] for creating and attaching to the virtual machine.

Hmmm, and that works?

I’m not talking about resizing the image; I fully expect that to work as long as you’re not sandboxed. I’m talking about booting the macOS guest from the resized disk image and having it recognise the additional space. I coulda sworn there was some roadblock there.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hmmm, and that works?

Yes it works. there are some blocks like relocating the recovery partition to end( that can be done) and after that using disk utility we can resize main partition. but the hdiutil snadbox limitation makes not possible to do with appstore app. may be ,i need to release a separate tool for this without app sandbox to get it done.

Yes it works.

Well, that’s cool.

Unfortunately it puts the kibosh on all the workaround ideas I’d been thinking of. It might’ve been feasible for you to manually resize less complex disk images, but doing that for a .dmg containing a bootable macOS is not feasible. You really need hdiutil for this.

I’m gonna recommend that you file a couple of bugs here:

  • A bug report asking that hdiutil support this use case. Resizing a macOS boot image from a Mac App Store hypervisor app is a reasonable thing to do, and it’s annoying that it’s being blocked by the sandbox.

  • A separate enhancement request for an API to manipulate disk images programatically. Relying on hdiutil for these sorts of tasks has always been annoying, and it’s gonna get increasingly problematic as we get further down the virtualisation path.

Please post your bug numbers, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Here is the bug report number FB17262771

Resize disk image with hdiutil in sandbox environment
 
 
Q