cirruslabs / packer-plugin-tart

Packer builder for Tart VMs
https://developer.hashicorp.com/packer/plugins/builders/tart
Mozilla Public License 2.0
65 stars 16 forks source link

Cannot extend the image with "Error: -69519: The target disk is too small for this operation" #149

Closed sc0rp10 closed 4 months ago

sc0rp10 commented 4 months ago

Hi! I'm testing the Packer integration with tart to achieve some desired hierarchy of macOS VMs (like the cirruslabs/macos-image-templates but in my own way).

I created a base image with vanilla Sonoma with disk_size_gb = 30, then I extended the base image with few additions like XCode with disk_size_gb = 90, but currently I'm unable to build the xcode-containing image due to error:

Error: -69519: The target disk is too small for this operation, or a gap is required in your partition map which is missing or too small, which is often caused by an attempt to grow a partition beyond the beginning of another partition or beyond the end of partition map usable space

Which part is this error related to? My workstation? Incorrect initialization of base image? How can I solve it?

Thanks!

edigaryev commented 4 months ago
  1. Which version of Packer Plugin Tart are you running?
  2. Which version of Tart are you running?
  3. Which macOS version are you trying to run in the guest?

Also, please provide a minimally reproducing example of a .pkr.hcl that reproduces the issue.

The error itself most likely comes from the diskutil apfs resizeContainer that we run inside of a guest to finalize the partition resizing that you've requested via disk_size_gb.

sc0rp10 commented 4 months ago

Hi, @edigaryev super sorry for not detailed report - literally forgot to post the second message with the details:

Packer plugin:

$ packer plugins installed
/opt/homebrew/bin/github.com/cirruslabs/tart/packer-plugin-tart_v1.11.1_x5.0_darwin_arm64

Tart itself:

$ tart --version
2.9.0

The Host OS:

$ sw_vers
ProductName:            macOS
ProductVersion:         14.3.1
BuildVersion:           23D60

The base.pkr.hcl is completely equivalent to the https://github.com/cirruslabs/macos-image-templates/blob/master/templates/vanilla-sonoma.pkr.hcl Part related to the disk:

source "tart-cli" "tart" {
  from_ipsw    = "https://updates.cdn-apple.com/2024WinterFCS/fullrestores/052-77579/4569734E-120C-4F31-AD08-FC1FF825D059/UniversalMac_14.4.1_23E224_Restore.ipsw"
  vm_name      = "sonoma-base"
  cpu_count    = 4
  memory_gb    = 8
  disk_size_gb = 20 # here is the base disk size
  ssh_password = "admin"
  ssh_username = "admin"
  ssh_timeout  = "120s"
  boot_command = [
    # skip boot commands
  ]
  create_grace_time = "30s"
}

The xcode.pkr.hcl:

source "tart-cli" "tart" {
  vm_base_name = "ghcr.io/ourteamname/sonoma-base:latest" # extends the previous `base.pkr.hcl`
  vm_name      = "${var.macos_version}-xcode:${var.xcode_version}"
  cpu_count    = 4
  memory_gb    = 8
  disk_size_gb = 90 # here is the increased disk size
  headless     = true
  ssh_password = "admin"
  ssh_username = "admin"
  ssh_timeout  = "120s"
}
edigaryev commented 4 months ago

Should be fixed now as of release 1.12.0.