-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resize disk0.img with macOS VM #4186
Comments
This isn't possible in UTM. I found this article that explains how to resize a disk image on Mac - could you please try and see if it works for your case? Make sure you have a backup of the file in case it gets damaged in your experimentation! |
I experimented with this some today — I was hoping to grow a macOS (M1) guest big enough that I could install system updates within it, without having to set up everything inside again. I was able to make some progress but at this point didn't succeed. Based on the tips in #2636 I started with
The At this point the VM still boots just fine and I do have a larger "Virtual Block Media" device ("Show All Devices" in guest Disk Utility app) so it's off to a good start! But unfortunately that's about as far as I can get, afaict, due to the partition arrangement: It looks the original arrangement of the disk is:
I don't think I can resize the partition for the main APFS container, without first moving or removing the recovery partition. See https://apple.stackexchange.com/questions/364288/how-to-resize-grow-apfs-partition-that-is-at-the-end-of-the-drive which provided examples for some of the commands I tried. Since my host is also Monterrey it looks like I won't be able to boot into recovery mode (see #3526) so I haven't tried anything from there. I suppose it might be possible to mount this whole UPDATE: I won't likely pursue this any further in the near future. By temporarily setting both the old and a clean-install new VM to "bridge" networking mode, I was able to use Migration Assistant to transfer over earlier work/settings from my original guest, into a new guest with a larger disk. (I also tried using a second disk image as a Time Machine backup volume, also aiming to use Migration Assistant but only on the new VM. That attempt also failed — it seemed like the source/original guest was seeing the extra volume as "internal" and perhaps doing something different with encryption "keybag" than it would an external? Or… something? Basically I could get a second "disk1.img" to work fine as a Time Machine volume within the first VM. But then after shutting down the first and adding the same "disk1.img" to the second VM, it would see the block drive but refuse to mount or "first aid" the APFS container within, not ever prompting for password just going straight to cryptic errors like:
and:
didn't fully troubleshoot but it just didn't want to use the drive. My wild guess is that internal APFS drives get encrypted directly to the host CPU or something, whereas external can be moved between machines, but who knows…?) |
Hi @natevw thanks for your post! I found it helpful trying to resize a Mac OS 14 image myself.
It turns out some of the software I had licensed didn't work well with the migration assistant transfer. So what I did instead was resize the main partition.
Exactly, so I went ahead and deleted the recovery partition. Here's exactly what I did:
What's cool is I can still boot into Recovery mode using UTM, because the initial 500 MB partition is still there. I figure this is a VM, so do I really need the 5.4 GB Special thanks to: |
I followed the steps above and I can extend the the UTM image using gemu-img |
@barak-kalai , try repairing the internal disk before resizing the synthesized. Something like this:
|
Why would you need any external tools for resizing if on macOS the image can be resized natively?
So, basically, I did the following:
|
Please note that the steps below help if you want to recover the 5.4 GB from the Apple_APFS_Recovery partition to make your images as optimized as possible, but further OS update will probably fail. Thanks @galaxy4public. I think everything can be done directly from recovery (at least it worked well for me). In that case the simplified steps are:
|
If you want to be able to increase the size of your disk image while retaining the ability to upgrade your OS, the Apple_APFS_Recovery partition must be relocated to the end of the disk before expanding the main Apple_APFS container. So far the only ready-made solution I have found is the Tart packer plugin from the Tart project by cirruslabs which allows for automated VM creation and has the option to automatically resize disk images (see the More information on the projects can be found below: Since I wanted to continue using UTM and simply needed a standalone tool to relocate the partition, I created a small tool based on their code. Understand that it come with no guarantee, but the code is available here: To build it, install go (with brew for instance) and execute the few commands listed in the comments at the beginning of the file. Considering that, the full instructions are:
|
booting in recovery mode leads to a black screen on all VMs. Any idea how to fix that? |
Is there a way how to resize an existing disk (the primary one) of an macOS VM? It defaults to 64GB and thanks to APFS it occupies only the real size of data within (via du -sh on the disk image) even though Finder reports 64GB (via Get Info on the disk image).
This all works well with APFS "magic" 🪄 but if I want to backup the VM to an external non-APFS it will occupy all of the 64GB.
So the workaround I tried is to install macOS Monterey with the minimal disk size (24GB), but now I have only 2GB of free space left. Is there a way how I can resize the disk of an existing VM? I understand I could always create a new disk and attach it to the VM, but what about resizing the (primary) disk of the VM? Is that at all possible with macOS?
The text was updated successfully, but these errors were encountered: