increasing .img disk size #238

Open
opened 2025-12-29 05:25:39 +01:00 by adam · 3 comments
Owner

Originally created by @omarahm3 on GitHub (Aug 28, 2021).

Hey i'm using this image here: https://images.sick.codes/mac_hdd_ng_auto_big_sur.img and i want to increase it's disk size so I did try the approach mentioned in https://github.com/sickcodes/Docker-OSX/issues/13#issuecomment-785604848 and this one too and it did work first time.

Then i needed to increase the disk size again so i can install command line developer tools, so i did it again and now its not actually resizing the disk size of the image. The only thing that increases is the virtual size, and disk size is still constant even after running diskutil apfs resizeContainer command

Here is the output of qemu-img info mac_hdd_ng_auto_big_sur.img

image: mac_hdd_ng_auto_big_sur.img
file format: qcow2
virtual size: 229 GiB (245695516672 bytes)
disk size: 48.7 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

so Is there any other approach to do this? or any leads on how to debug that as i'm pretty new to KVM and qemu

much appreciated all

Originally created by @omarahm3 on GitHub (Aug 28, 2021). Hey i'm using this image here: https://images.sick.codes/mac_hdd_ng_auto_big_sur.img and i want to increase it's disk size so I did try the approach mentioned in https://github.com/sickcodes/Docker-OSX/issues/13#issuecomment-785604848 and this [one](https://jochendelabie.com/2020/05/19/resizing-an-osx-vm-with-apfs-and-qemu/) too and it did work first time. Then i needed to increase the disk size again so i can install command line developer tools, so i did it again and now its not actually resizing the disk size of the image. The only thing that increases is the virtual size, and disk size is still constant even after running `diskutil apfs resizeContainer` command Here is the output of `qemu-img info mac_hdd_ng_auto_big_sur.img` ``` image: mac_hdd_ng_auto_big_sur.img file format: qcow2 virtual size: 229 GiB (245695516672 bytes) disk size: 48.7 GiB cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false refcount bits: 16 corrupt: false ``` so Is there any other approach to do this? or any leads on how to debug that as i'm pretty new to KVM and qemu much appreciated all
Author
Owner

@sickcodes commented on GitHub (Aug 30, 2021):

Yeah that image isn't supposed to be there because of I tried to shrink it then expand it etc.

I couldn't get it to grow back 😂

Might make another soon

@sickcodes commented on GitHub (Aug 30, 2021): Yeah that image isn't supposed to be there because of I tried to shrink it then expand it etc. I couldn't get it to grow back 😂 Might make another soon
Author
Owner

@omarahm3 commented on GitHub (Aug 30, 2021):

@sickcodes I can imagine the effort yeah 😂

Are there any docs or references you recommend to create an image, perhaps i can help with this

@omarahm3 commented on GitHub (Aug 30, 2021): @sickcodes I can imagine the effort yeah :joy: Are there any docs or references you recommend to create an image, perhaps i can help with this
Author
Owner

@mtfurlan commented on GitHub (Jun 6, 2022):

I resized that image by

qemu-img resize mac_hdd_ng_auto_big_sur.img +$whateverBiggerYouWant
sudo qemu-nbd --connect=/dev/nbd0 ./mac_hdd_ng_auto_big_sur.img
sudo gdisk /dev/nbd0
# delete partition 2, create new partition 2 of a bigger size
sudo qemu-nbd --disconnect /dev/nbd0
# boot the image and do the rest inside osx
diskutil list
# using the names pick the right thing to resize
diskutil apfs resizeContainer disk1s2 $whateverSizeItHas

I'm not sure that messing with the partitions with gdisk was necessary because I think the apfs resizeContainer did the same thing, but it didn't break anything either.

@mtfurlan commented on GitHub (Jun 6, 2022): I resized that image by ```bash qemu-img resize mac_hdd_ng_auto_big_sur.img +$whateverBiggerYouWant sudo qemu-nbd --connect=/dev/nbd0 ./mac_hdd_ng_auto_big_sur.img sudo gdisk /dev/nbd0 # delete partition 2, create new partition 2 of a bigger size sudo qemu-nbd --disconnect /dev/nbd0 # boot the image and do the rest inside osx diskutil list # using the names pick the right thing to resize diskutil apfs resizeContainer disk1s2 $whateverSizeItHas ``` I'm not sure that messing with the partitions with gdisk was necessary because I think the apfs resizeContainer did the same thing, but it didn't break anything either.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Docker-OSX-sickcodes#238