Docker-OSX icon indicating copy to clipboard operation
Docker-OSX copied to clipboard

increasing .img disk size

Open omarahm3 opened this issue 4 years ago • 3 comments

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

omarahm3 avatar Aug 28 '21 13:08 omarahm3

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 avatar Aug 29 '21 23:08 sickcodes

@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

omarahm3 avatar Aug 30 '21 15:08 omarahm3

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 avatar Jun 06 '22 17:06 mtfurlan